Skip to content

Fix for running Task Sequence from toast #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions New-ToastNotification.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

.NOTES
Filename: New-ToastNotification.ps1
Version: 2.3.0
Version: 2.3.1
Author: Martin Bengtsson
Blog: www.imab.dk
Twitter: @mwbengtsson
Expand Down Expand Up @@ -82,18 +82,18 @@
** As well as added support for dynamic deadline retrieval for software updates **
** Stuff has been rewritten to suit my understanding and thoughts of the script **

2.0.0 - Huge changes to how this script handles custom protocols
Added Support for Custom Actions/Protocols within the script under user context removing the need for that to be run under SYSTEM/ADMIN
- <Option Name="Action" Value="ToastRunUpdateID:" />
- <Option Name="Action" Value="ToastRunPackageID:" />
- <Option Name="Action" Value="ToastRunApplicationID:" />
- <Option Name="Action" Value="ToastReboot:" />
Added Support to dynamically create Custom Action Scripts to support Custom Protocols
Added Support for Software (Feature) Updates : Searches for an update and will store in variable
Added new XML Types for Software Updates:
- <Option Name="RunUpdateID" Enabled="True" Value="3012973" />
- <Option Name="RunUpdateTitle" Enabled="True" Value="Version 1909" />
Added support for getting deadline date/time dynamically for software updates
2.0.0 - Huge changes to how this script handles custom protocols
Added Support for Custom Actions/Protocols within the script under user context removing the need for that to be run under SYSTEM/ADMIN
- <Option Name="Action" Value="ToastRunUpdateID:" />
- <Option Name="Action" Value="ToastRunPackageID:" />
- <Option Name="Action" Value="ToastRunApplicationID:" />
- <Option Name="Action" Value="ToastReboot:" />
Added Support to dynamically create Custom Action Scripts to support Custom Protocols
Added Support for Software (Feature) Updates : Searches for an update and will store in variable
Added new XML Types for Software Updates:
- <Option Name="RunUpdateID" Enabled="True" Value="3012973" />
- <Option Name="RunUpdateTitle" Enabled="True" Value="Version 1909" />
Added support for getting deadline date/time dynamically for software updates
- Configure DynamicDeadline with the UpdateID

2.0.1 - Updated custom action scripts!
Expand All @@ -106,7 +106,7 @@
- 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
Added support for getting deadline date/time dynamically for applications
- Configure DynamicDeadline with the Application ID

2.0.2 - Fixed an error in the custom protocols
Expand Down Expand Up @@ -137,7 +137,7 @@
- The function then uses this name, to create a custom app for doing the notification.
- This will reflect in the shown toast notification, instead of Software Center or PowerShell
- This also creates the custom notifcation app with a prevention from disabling the toast notifications via the UI

2.3.1 - Changed ToastRunPackageID script to use Invoke-CimMethod instead of calling wmi to succesfully run task sequences from script
.LINK
https://www.imab.dk/windows-10-toast-notification-script/
#>
Expand Down Expand Up @@ -1014,8 +1014,12 @@ $RegistryPath = "HKCU:\SOFTWARE\ToastNotificationScript"
$PackageID = (Get-ItemProperty -Path $RegistryPath -Name "RunPackageID").RunPackageID
$TestPackageID = Get-WmiObject -Namespace ROOT\ccm\ClientSDK -Query "SELECT * FROM CCM_Program where PackageID = '$PackageID'"
if (-NOT[string]::IsNullOrEmpty($TestPackageID)) {
$ProgramID = $TestPackageID.ProgramID
([wmiclass]'ROOT\ccm\ClientSDK:CCM_ProgramsManager').ExecuteProgram($ProgramID,$PackageID)
$arguments = @{
'PackageID' = $PackageID
'ProgramID' = $TestPackageID.ProgramID
}
[cimclass]$CimClass = (Get-CimClass -Namespace 'Root\ccm\clientsdk' -ClassName 'CCM_ProgramsManager')
Invoke-CimMethod -CimClass $CimClass -MethodName 'ExecuteProgram' -Arguments $Arguments
if (Test-Path -Path "$env:windir\CCM\ClientUX\SCClient.exe") { Start-Process -FilePath "$env:windir\CCM\ClientUX\SCClient.exe" -ArgumentList "SoftwareCenter:Page=OSD" -WindowStyle Maximized }
}
exit 0
Expand Down Expand Up @@ -2562,4 +2566,4 @@ if (($UpgradeOS -ne "True") -AND ($PendingRebootCheck -ne "True") -AND ($Pending
else {
Write-Log -Level Warn -Message "Conditions for displaying default toast notification are not fulfilled"
}
#endregion
#endregion