Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Andy_Sismey
Champion Sweeper III


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"

 

5 REPLIES 5
gcrucitti
Engaged Sweeper II

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?

gcrucitti
Engaged Sweeper II

.

gcrucitti
Engaged Sweeper II

Adding this line do not resolve.

  <ToastContent>
    <ToastContent ToastScenariotype="Alarm"/> 
  </ToastContent>

Notifications do not appear and are only in the notifications menu.

 

gcrucitti
Engaged Sweeper II

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)

 

LANGuy1
Engaged Sweeper

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

Deployment Packages

Share topics/ issues related to deployment packages. Please use/rely on content with caution as it is publicly generated.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now