I am working on a scheduled restart toasts using the Burnt Toast module. To add a selection box to have them schedule a time to do the restart(1 hour, 2 hours, etc..) and handle the action events, I need Powershell 7.1 or above. I have code that works when I run it directly from powershell 7.2.
The issue I have is that when we send this to our user's computers, the script will run in powershell 5.1, not 7.2. No way we can change that. I get a message saying "Toast events are only supported on Powershell 7.1.0 and above. Your notification will still be displayed, but the actions will be ignored." And like it says, it displays the toast but does not do the action.
What I am trying to do now is use either powershell 5.1 or command script to call powershell 7.2 so the script can run that way.
In powershell 5.1, I am running this command: Invoke-Expression -Command "C:'Program Files'\PowerShell\7\pwsh.exe -Command C:\Setup\Scripts\ScheduledRestartToast.ps1"
In command script, I am running this command: "c:\Program Files\PowerShell\7\pwsh.exe" -command "c:\Setup\Scripts\ScheduledRestartToast.ps1"
Both of these display the toast, but neither of them actually does the action.
Is it possible to have Powershell 7 run actionable scripts this way?
Thanks
I found that If I do this instead:
it will keep the window open until they perform the action.