I have an older PowerShell script created by a colleague that checks the uptime of a machine. If the uptime exceeds seven days, it starts a countdown and shows a pop-up reminder every hour advising the user to restart. It worked perfectly in Windows 10, but after upgrading to Windows 11, I'm encountering issues. Now the countdown also opens a hidden PowerShell window, which is visible and stays active, displaying information about the job. I'm not sure what's causing this change in behavior. Can anyone help me understand why this is happening?
3 Answers
I found the answer! Windows 11 does indeed treat Scheduled Tasks differently. I discovered a small VB script that launches my PowerShell script and keeps the PowerShell window hidden, solving the issue for me.
Just to clarify, how is your script started in the Task Scheduler? When you open your task in the scheduler and check the Actions tab, what program path and arguments are used? It might give more insight into why it’s showing up like this.
The way Windows 11 handles PowerShell job windows is different from Windows 10. It seems that instead of running them in the background, it now brings them to the front when anything is outputted. You might want to try running your script using `powershell.exe -WindowStyle Hidden` or wrap your job inside a `Start-Process` command with the `-WindowStyle Hidden` option to keep it from popping up. Also, just curious, is the pop-up triggered by the Task Scheduler?
Yes, we have a proactive remediation set up that checks uptime and triggers the scheduled task based on that.
It’s an automatic task that triggers once the machine has been on for more than seven days.