‎08-11-2021 01:18 PM - last edited on ‎06-30-2023 03:14 PM by ErikT
Its always handy to ask the User to reboot once the install has finished, here is a simple TOAST message with Image (445 x 266) to add to the end of the deployment...
Edit the following Powershell with the message, image location etc
copy-Item "***Path To Images***\images\reboot.png" -Destination "C:\temp"
Start-Sleep -Seconds 3
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
#Gets the Template XML so we can manipulate the values
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Computer Reboot Required</text>
<image placement="inline" src="c:\temp\reboot.png" />
<text>Please reboot your computer to complete the installation of NEW Features and Important Updates.</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Close" arguments="later"/>
</actions>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$notify.Show($ToastXml)
Th Command Required :
powershell.exe -executionpolicy bypass -file "\\Server\defaultpackageshare$\software\messages\Reboot.ps1"
‎09-02-2022 02:58 PM - edited ‎09-02-2022 03:34 PM
Very nice script.
Is it possible to set the notification to run when user notificatios is set to do not disturb?
In "imab" script its possible to set.
<Option Name="Scenario" Type="alarm" />
This option apply on your script?
‎09-02-2022 03:33 PM - edited ‎09-02-2022 03:34 PM
.
‎09-02-2022 03:54 PM
Adding this line do not resolve.
<ToastContent>
<ToastContent ToastScenariotype="Alarm"/>
</ToastContent>
Notifications do not appear and are only in the notifications menu.
‎09-02-2022 10:40 PM
I found a way to notify with focus assistant enabled.
Use "scenario="alarm" in "toast launch" and disable Alarm Audio with "<audio silent="true"/>"
copy-Item "***Path To Images***\images\reboot.png" -Destination "C:\temp"
Start-Sleep -Seconds 3
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
#Gets the Template XML so we can manipulate the values
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
[xml]$ToastTemplate = @"
<toast launch="app-defined-string" scenario="alarm">
<visual>
<binding template="ToastGeneric">
<text>Computer Reboot Required</text>
<image placement="inline" src="c:\temp\reboot.png" />
<text>Please reboot your computer to complete the installation of NEW Features and Important Updates.</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Close" arguments="later"/>
</actions>
<audio silent="true"/>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$notify.Show($ToastXml)
‎08-12-2022 08:53 PM
Errors for me. I'm running this on my own machine as a local admin.
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False ToastNotificationManager System.Runtime.InteropServices.Windo...
Exception calling "Show" with "1" argument(s): "Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED))"
At line:36 char:1
+ $notify.Show($ToastXml)
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now