Created
July 17, 2020 10:24
-
-
Save KelvinTegelaar/a195e129935cff92d555be7334e7bc5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Checking if ToastReboot:// protocol handler is present | |
| New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -erroraction silentlycontinue | out-null | |
| $ProtocolHandler = get-item 'HKCR:\ToastReboot' -erroraction 'silentlycontinue' | |
| if (!$ProtocolHandler) { | |
| #create handler for reboot | |
| New-item 'HKCR:\ToastReboot' -force | |
| set-itemproperty 'HKCR:\ToastReboot' -name '(DEFAULT)' -value 'url:ToastReboot' -force | |
| set-itemproperty 'HKCR:\ToastReboot' -name 'URL Protocol' -value '' -force | |
| New-item 'HKCR:\ToastReboot\Shell\Open\command' -force | |
| set-itemproperty 'HKCR:\ToastReboot\Shell\Open\command' -name '(DEFAULT)' -value 'C:\Windows\System32\shutdown.exe -r -t 60' -force | |
| } | |
| Install-Module -Name BurntToast | |
| Install-module -Name RunAsUser | |
| invoke-ascurrentuser -scriptblock { | |
| $heroimage = New-BTImage -Source 'C:\Users\Kelvin\OneDrive - Lime Networks BV\Bureaublad\Scripts\toast\ToastHeroImagePlain.png' -HeroImage | |
| $Text1 = New-BTText -Content "Message from Lime Networks" | |
| $Text2 = New-BTText -Content "Lime Networks has installed updates on your computer. Please select if you'd like to reboot now, or snooze this message." | |
| $Button = New-BTButton -Content "Snooze" -snooze -id 'SnoozeTime' | |
| $Button2 = New-BTButton -Content "Reboot now" -Arguments "ToastReboot://" -ActivationType Protocol | |
| $5Min = New-BTSelectionBoxItem -Id 5 -Content '5 minutes' | |
| $10Min = New-BTSelectionBoxItem -Id 10 -Content '10 minutes' | |
| $1Hour = New-BTSelectionBoxItem -Id 60 -Content '1 hour' | |
| $4Hour = New-BTSelectionBoxItem -Id 240 -Content '4 hours' | |
| $1Day = New-BTSelectionBoxItem -Id 1440 -Content '1 day' | |
| $Items = $5Min, $10Min, $1Hour, $4Hour, $1Day | |
| $SelectionBox = New-BTInput -Id 'SnoozeTime' -DefaultSelectionBoxItemId 10 -Items $Items | |
| $action = New-BTAction -Buttons $Button, $Button2 -inputs $SelectionBox | |
| $Binding = New-BTBinding -Children $text1, $text2 -HeroImage $heroimage | |
| $Visual = New-BTVisual -BindingGeneric $Binding | |
| $Content = New-BTContent -Visual $Visual -Actions $action | |
| Submit-BTNotification -Content $Content | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment