diff --git a/Toast_Notify.ps1 b/Toast_Notify.ps1 index 5a34378..815f3b7 100644 --- a/Toast_Notify.ps1 +++ b/Toast_Notify.ps1 @@ -5,6 +5,14 @@ Created by: Ben Whitmore Filename: Toast_Notify.ps1 =========================================================================== +Version 1.2.26 - 26/01/2021 +-Changed the Scheduled Task to run as -GroupId "S-1-5-32-545" (USERS). +When Toast_Notify.ps1 is deployed as SYSTEM, the scheduled task will be created to run in the context of the Group "Users". +This means the Toast will pop for the logged on user even if the username was unobtainable (During testing AzureAD Joined Computers did not populate (Win32_ComputerSystem).Username). +The Toast will also be staged in the $ENV:Windir "Temp\$($ToastGuid)" folder if the logged on user information could not be found. +Thanks @CodyMathis123 for the inspiration via https://github.com/CodyMathis123/CM-Ramblings/blob/master/New-PostTeamsMachineWideInstallScheduledTask.ps1 + + Version 1.2.14 - 14/01/21 -Fixed logic to return logged on DisplayName - Thanks @MMelkersen -Changed the way we retrieve the SID for the current user variable $LoggedOnUserSID @@ -164,7 +172,7 @@ If ($XMLValid -eq $True) { } $Task_Trigger = New-ScheduledTaskTrigger -Once -At $Task_TimeToRun $Task_Trigger.EndBoundary = $Task_Expiry - $Task_Principal = New-ScheduledTaskPrincipal -UserId $LoggedOnUserName -LogonType ServiceAccount + $Task_Principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-545" -RunLevel Limited $Task_Settings = New-ScheduledTaskSettingsSet -Compatibility V1 -DeleteExpiredTaskAfter (New-TimeSpan -Seconds 600) $New_Task = New-ScheduledTask -Description "Toast_Notification_$($LoggedOnUserSID)_$($ToastGuid) Task for user notification. Title: $($EventTitle) :: Event:$($EventText) :: Source Path: $($LoggedOnUserToastPath) " -Action $Task_Action -Principal $Task_Principal -Trigger $Task_Trigger -Settings $Task_Settings Register-ScheduledTask -TaskName "Toast_Notification_$($LoggedOnUserSID)_$($ToastGuid)" -InputObject $New_Task