Coder Social home page Coder Social logo

Comments (3)

imabdk avatar imabdk commented on August 12, 2024

Thank you for the suggestion.

I usually suggest using the collections in configmgr for this purpose, but I see how collection refreshes combined with how often hardware inventory is run can results in unwanted toast notifications. Added to my 'might do-list'. Another possibility is that I add the option to only allow the toast notification to run once a day regardless of how the deployment schedule in configmgr may be configured.

from toast-notification-script.

ztrhgf avatar ztrhgf commented on August 12, 2024

It should be easy modification. Just add this code at start of function Display-ToastNotification:

if ($RunApplicationIDValue -and $RunApplicationIDEnabled -eq "True") {
    $TestApplicationID = Get-CimInstance -ClassName CCM_Application -Namespace ROOT\ccm\ClientSDK -ea SilentlyContinue | Where-Object { $_.Id -eq $RunApplicationIDValue }

    if ($TestApplicationID -and $TestApplicationID.InstallState -eq "Installed") {
        Write-Log -Message "Application $RunApplicationID is already installed. Toast notification won't be displayed"
        return
    }
}

So in case, that you define RunApplicationID XML tag, and such application will be already installed, notification won't show.
Of course this code can be placed earlier in the New-ToastNotification script, for sake of better effeciency..

from toast-notification-script.

kheldorn avatar kheldorn commented on August 12, 2024

I went a slightly different route and added the following code towards the end of the script, just before it defaults to the fallback toast notification.

# Toast used for Application installation
if ($RunApplicationIDValue -and $RunApplicationIDEnabled -eq "True") {
    $TestApplicationID = Get-CimInstance -ClassName CCM_Application -Namespace ROOT\ccm\ClientSDK -ErrorAction SilentlyContinue | Where-Object { $_.Id -eq $RunApplicationIDValue }

    if ($TestApplicationID -and $TestApplicationID.InstallState -eq "Installed") {
        Write-Log -Message "Application $RunApplicationIDValue is already installed. Toast notification won't be displayed"
    }
    else {
        Write-Log -Message "Application $RunApplicationIDValue is not installed. Displaying toast notification"
        Display-ToastNotification
    }
    # Stopping script. No need to accidently run further toasts
    break
}

from toast-notification-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.