Windows 10 Toast Notification Script Update (Poolside Release): Dynamic Application deadline and custom action scripts updates

Introduction

This is just a minor release, with me making some few adjustments and further polishing of the script while being on vacation (hence the poolside reference). 😀

  • I’ve added the option to retrieve deployment deadline of applications dynamically, as well as reworked some of the custom scripts area.
  • Everything related to the script, is now located within the user’s profile in AppData\Roaming\ToastNotificationScript.
  • Custom scripts are moving away from ProgramData into AppData\Roaming\ToastNotificationScript\Scripts.

The script is now on version 2.0.2. Find all the details down below.

What’s New

  • 2.0.2 – Fixed an error in the custom protocols
    • The path to the custom scripts was incomplete
  • 2.0.1 – Updated custom action scripts!
    • Moved all custom action scripts into the user’s profile in $env:APPDATA\ToastNotificationScript
      • $env:ALLUSERSPROFILE was used previously. This is a bad location if device is used by multiple users due to permission issues
    • Updated all custom action scripts to invoke their respective action via WMI
      • Rewritten all custom action scripts
    • Added logic allowing new custom action scripts to be created if necessary
      • Now checks script version in registry
      • If newer version is available from the script, new custom action scripts will be created
        • This allows me to make sure the relevant scripts are in place in case I change something along the way
    • Modified script output of custom script for RunPackageID to pick up Program ID dynamically
  • Added support for getting deadline date/time dynamically for applications
    • Configure DynamicDeadline with the Application ID

Config.xml

No changes are happening to the content of the config.xml.

However, the DynamicDeadline option now also supports looking up deadline details based on Application ID.

To look up deadline details based on a deployment of an Application, configure DynamicDeadline to Enabled=”True” and specify the Application ID  in the Value portion: Value=”ScopeId_A9117680-D054-482B-BC97-532E6CBD0E6B/Application_fd55f35c-4e34-4490-a3ec-ee0b79233ec6″ />

You can find the Application ID by querying WMI or by browsing the application in the Software Center.

Query WMI

Use below line of Powershell to get the Application ID based on the exact name of the application. Run this from a device, where the application is deployed.

Get-CimInstance -ClassName CCM_Application -Namespace ROOT\ccm\ClientSDK | Where-Object {$_.Name -eq "<Insert exact name of application>"} | Select-Object Id

Software Center

When browsing the application via the Software Center, you will find the Share button. Using this, will also reveal the Application ID of the application.

Custom Action Scripts

The custom action scripts has moved into the user’s profile, away from $env:ALLUSERSPROFILE, putting the scripts into the same directory as the script’s log file: New-ToastNotification.log

I did this because permission issues otherwise will occur, if multiple users are sharing the same device, and the content of the scripts needs to be updated.

I also added some version control for custom scripts and protocols.

If a new version of the script is run on a device, new custom scripts and protocols will be created. Otherwise nothing will be created.

This enables me to make sure the relevant scripts and protocols are used, without always and each time the script is run, to create custom scripts and protocols.

Download

Download everything from GitHub here: https://github.com/imabdk/Toast-Notification-Script

If any questions, please leave them down below and I am happy to assist with any issues.

ENJOY (a picture of me on vacation) 😀

27 thoughts on “Windows 10 Toast Notification Script Update (Poolside Release): Dynamic Application deadline and custom action scripts updates”

  1. Martin,

    Impressive stuff, thank you for sharing.

    I have the older virions working AOK but thought of taking the new one for a ride, I was testing this version and apparently the path is messed up here.

    Computer\HKEY_CURRENT_USER\Software\Classes\ToastRunUpdateID\shell\open\command
    only shows: \ToastRunUpdateID.cmd as value instead of the whole path, and so when you click on the Upgrade now button from the toast you get no action.

    Did verify the scripts folder and all the cmd and ps1 files are already populated., and of course if I manually run the cmd file then it does the job to open the software center and also triggers the update right away.

    Either I’m too sleepy to have messed up the config or something is wrong here.

    Here is my config file: https://anjipubfiles.blob.core.windows.net/toast/config-toast-waasfu-2004.xml

    Can you please take a look at it when you have a moment.

    Much appreciated.

    Reply
    • Darn! You are right. I found the error. I will upload a new version to GitHub asap. Sorry about that and thanks a bunch for making me aware. I will let you know once corrected. Thanks again 🙂

      Reply
      • Hi,

        same Problem here. The Action Button is without function. The message will serach an App in the Microsoft Store.
        Path´s and RegKey´s are correct and available. If i start the ToastRunUpdateID.cmd manually the Feature Update is running.

        Reply
        • What happens if you run toastrunupdateid: directly from Run in Windows? How does your registry look like when browsing HKCU:\Software\Classes\ToastRunUpdateID? If you want, you are welcome to take this offline with me on mab@imab.dk. I’m very keen to finding out if I introduced something weird. I just tested the script again and again in my end, and the custom protocols (those residing in hkcu\software\classes) are getting created just fine. Let me know.

          Reply
      • It’s my pleasure, we could at least test things that you awesome guys make. 🙂

        Thanks for the quick fix, will test again and let you know.

        Reply
  2. I wish, I could use your script, I tried but failed. Could you make a step by step instruction videos about the script notification and how to deploy. That would be helpful for techs that are more visual like me. Thank you in advance.

    Reply
    • Can you let me know which part that failed? I leave the script in a state, that when run manually directly from the download, a toast notification will display about computer uptime.

      Reply
      • I agree with this. It’s not that easy to combine info from 5 blog posts into something working if you’re not a full time SCCM admin.

        Reply
        • I hear you. I admit it can be overwhelming with the amount of details and options. I’m happy to assist with any specific issue you encounter. I don’t see myself finding more time to do videos as well I’m afraid. I’m trying my best to keep the posts and documentation on point. Let me know if you need assistance with anything specific. 🙂

          Reply
  3. Hi Martin,
    first of all – than you for your work! I really like your Toast Notification platform!

    Second, maybe Im doing something wrong, but let me ask. When there is an application / update with a deadline and I throw a popup to the user, script check its deadline in WMI. Lets assume one user reacts immediately and install the application / update. When I throw popup again it is displayed again even though the application / update is already installed.
    Is there any way how to prevent this happening? Do not display the popup once the app / update is installed?

    Im now using custom launcher like this before running your Toast Notification script but it is not very convenient:

    $Application = Get-WmiObject -Class ccm_application -Namespace root\ccm\clientsdk | Where {$_.Name -like ‘*My Application*’}
    If ($Application.InstallState -eq “Installed”) {EXIT}
    Else {Run Toast}

    Reply
    • How much time, in between displaying the toast notifications for your users, do you have?

      This is something I usually take care of with the collections. Once the said application is installed, the device moves out of the collection to where your toast notification is deployed. Now, this is based on hardware inventory, and if you only run hardware inventory once a day, but triggers the same toast notification several times a day, I can see your troubles.

      Reply
    • Funny thing, I am also going through the same thing. I’ve deployed an application to software center and using the toast notification in order to notify the users, but after the users install the application they still get the notification. for context, I am deploying this to a user group. Martin’s collection suggestion works well if you target devices but not user groups.

      Reply
  4. Hi Martin,

    Thank you very much for all of your work on the Toast notification it has been a game changer for our comms.

    I just wanted to ask whether there was any scope to call Company Portal for the Install of an application instead of Software Center, this seems to be the direction Microsoft is pushing especially with the MECM Feature of setting Company Portal as the default portal.

    Reply
    • Hi Sam,

      That’s already somewhat achievable using the companyportal: protocol like so: companyportal:ApplicationId=bd8e6e11-bce5-411d-b391-15cda8289681

      If it’s possible to directly trigger the installation of an app is something I will look into.

      Thanks 🙂

      Reply
  5. I am getting this error but the package is deployed to the system, Its listed in softwarecenter.

    ERROR: PackageID: CHQ0000 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr

    Write-Host (Get-CimInstance -Namespace root\ccm\clientsdk -Query “SELECT * FROM CCM_Program WHERE PackageID = ‘CHQ0000′”) brings up nothing on the box.

    Reply
    • Package ID CHQ0000 seems suspiciously low. I’m sure you made a typo here and some digits are missing. CHQ is your site code and ‘0000’ should be the package. I don’t even think you can have a package ‘0’ and I’m sure a package id always consists of 8 digits. Yours are only 7.

      Reply
  6. Hi,

    I have been testing the toast notication and think its amazing. One quick question.
    I love how the Inplace Upgrade checks the build version before allowing the toast notifcation to run. Is there something similar we can do for 365 upgrades rather than waiting for hardware inventory \ collection refresh.

    e.g Script runs, 365 updates.
    The next day the program reruns the notification even though the user has already updated 365?

    I might have missed something, sorry if I have.

    Awesome work btw, this is amazing.

    Reply
    • Hi, I haven’t built in anything related to 365 updates. This is something I would manage using collections in configmgr. Once the device has upgraded and now is on a certain version, the device moves out of the collection where the toast notification script is deployed.

      Reply
  7. Hi Martin,
    thanks for a great tool!

    I would like to see an option where you can specify simple deadline like : 24h after you recieved this deployment it will install. is that possible with your toast notification system? Not knowing up front when exactly the toast will be run on a specific machine

    Reply
    • Hey Maarten, I’m not sure I follow. The deadline is solely managed by the deployment in ConfigMgr. You want to leave the application as available, and manage the deadline from within the toast notification. Say prompting to install the application, and if not done within xx period, automatically run the action which installs the application? 🙂

      Reply
  8. Hi Martin, great work as always!
    I think I’m doing something wrong. If I have RunApplicationID it opens the Software Center on the ‘Installation Status’ tab even though the application hasn’t been run yet. Likewise if I have RunPackageID set to a Task Sequences it just opens the Software Center on the ‘Operating Systems’ tab. It never actually open the application or task Sequence I have set in the config.

    Reply
    • Can you paste the content of the New-ToastNotification.log file for the situation? 🙂

      Hm, taking a closer look on my code, it shouldn’t launch Software center unless it actually verified that the appid or packageid is deployed to the device. So something when running the packageid via WMI is not right.

      What happens when running the script manually: C:\Users\mab\AppData\Roaming\ToastNotificationScript\Scripts\ToastRunPackageID.ps1

      Reply
  9. How can I make the action button open a URL using Firefox (or the default browser)? Do I have to make a custom application for that?

    Reply
  10. Hi Martin,

    I would like to only show the dismiss button and the more info action button, but not the install button when users are not connected to vpn..

    I only can disable actionbutton 1 AND 2 not only 1, could you help me with this?

    So now i got it working by addin this in your script:

    if ($getoutput -like ‘*195.169*’)

    {$ActionButton2Enabled = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘ActionButton2’} | Select-Object -ExpandProperty ‘Enabled’

    $ActionButton1Enabled = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘ActionButton1’} | Select-Object -ExpandProperty ‘Enabled’ }

    But would like to not show only action button 1 when vpn is NOT enabled, not both action buttons.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.