Why is My PowerShell Script Showing Hidden Windows in Windows 11?

0
1
Asked By SillyCat1234 On

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

Answered By ScriptGuru45 On

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.

Answered By CodeFixer99 On

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.

SillyCat1234 -

It’s an automatic task that triggers once the machine has been on for more than seven days.

Answered By QueryNinja71 On

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?

OldDogLearningNewTricks -

Yes, we have a proactive remediation set up that checks uptime and triggers the scheduled task based on that.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.