Software & OS

Why Does Windows PowerShell Keep Popping Up? How to Stop It

Windows PowerShell keeps popping up because something on your PC is starting it: a startup app, a scheduled task, or a script that runs on a timer or at sign-in. To stop it, find what launched the window, then disable that startup item or task.

The quickest way to find the culprit is to read the command line of the PowerShell process while the window is open. If the window disappears too fast to catch, the Task Scheduler and startup lists below show what is configured to run.

Why PowerShell opens by itself

PowerShell does not open on its own. Another program, task or script runs powershell.exe, and Windows shows a console window while it runs. These are the usual triggers:

  • A scheduled task. Windows, drivers, update tools and some installed apps register tasks in Task Scheduler. A task that runs powershell.exe every few minutes or at every sign-in produces a repeating window.
  • A startup app. Some apps start a PowerShell helper when you sign in, for example to check for updates or apply a setting.
  • A script you wrote or downloaded. A .ps1 file saved in a startup location, or a task you created once and forgot about.
  • A batch file or shortcut. A .bat file that calls powershell opens a console each time it runs.
  • Something unwanted. Malware also uses PowerShell, so a window you cannot trace to any program you installed is worth scanning for.

The window may also stay open or close at once. Per Microsoft's powershell.exe reference, the -NoExit parameter keeps the session open after startup commands run. Without it, a window that was started to run a script or command closes when the job ends. A one-second flash means a short job. A window that stays open and waits for you means -NoExit was used or the script is still running.

Step 1: See what command started the window

When the window is open, press Ctrl+Shift+Esc to open Task Manager and look for Windows PowerShell on the Processes tab. A shorter route is to ask Windows for the command line of every running PowerShell process. Open a separate PowerShell window and run:

Get-CimInstance Win32_Process -Filter "Name = 'powershell.exe'" | Select-Object ProcessId, CommandLine | Format-List

Example output (the file name and path are made up):

ProcessId   : 9120
CommandLine : "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File "C:\Tools\sync-backup.ps1"

ProcessId   : 14376
CommandLine : "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

The second entry is the window you are typing in. The first tells you the script that is running, C:\Tools\sync-backup.ps1. Use that path to find which program or task owns it. If the window you want to inspect is PowerShell 7 rather than Windows PowerShell, change the filter to 'pwsh.exe'.

If the process list is empty by the time you run the command, the job is too short to catch this way. Go on to the scheduled task and startup checks.

Step 2: Check Task Scheduler

Scheduled tasks are the most common cause of a window that repeats on a regular schedule. Press Win+R, type taskschd.msc, and press Enter. In the left pane, open Task Scheduler Library. Sort the middle list by Next Run Time or open each task's Actions tab to see which program it starts.

You can list every task that starts PowerShell in one command. Get-ScheduledTask returns the task definition objects registered on the computer, and each one has an Actions property:

Get-ScheduledTask | Where-Object { $_.Actions.Execute -match 'powershell|pwsh' } |
    Select-Object TaskPath, TaskName, State

Example output:

TaskPath                     TaskName          State
--------                     --------          -----
\                            SyncBackup        Ready
\Vendor\Updater\             CheckForUpdates   Ready

To see exactly what a task runs, print its action:

(Get-ScheduledTask -TaskName "SyncBackup").Actions | Format-List Execute, Arguments

Task names under \Microsoft\Windows\ belong to Windows itself. Leave those alone unless you know what a task does and why you are turning it off. Tasks in the root folder (\) or under a vendor's own folder are the better candidates.

When you have found the right task, right-click it in Task Scheduler and choose Disable. Disabling is reversible, so it is safer than deleting. From PowerShell, the matching cmdlet is Disable-ScheduledTask, listed in the Microsoft documentation alongside Get-ScheduledTask. Run it in an elevated window if Windows refuses the change:

Disable-ScheduledTask -TaskName "SyncBackup"

Step 3: Check startup apps

If the window appears right after you sign in, look at what starts at sign-in. Microsoft gives two places to manage this in Windows 11:

  1. Settings: select Start > Settings > Apps > Startup, then set an app's toggle to Off.
  2. Task Manager: right-click Start, choose Task Manager, open the Startup apps tab, select the app and choose Disable.

Task Manager also shows an Impact rating for each app, which helps you spot what slows sign-in. Microsoft's page notes that an app that is not in either list can be managed from File Explorer instead. In practice that means the Startup folder: press Win+R, type shell:startup, and check for shortcuts or .bat, .cmd and .ps1 files you do not recognise.

Step 4: Look at the script itself

Once you know the script path, open it in Notepad (do not run it). Short scripts that check for updates, sync a folder or clean a temp directory are normal. If you wrote the script and only want it to stop showing a window, you can change how the task starts it. Windows PowerShell accepts -WindowStyle with four values: Normal, Minimized, Maximized and Hidden. A task action using the hidden style looks like this:

powershell.exe -NoProfile -WindowStyle Hidden -File "C:\Tools\sync-backup.ps1"

Two other parameters are useful for tasks you own. -NoProfile skips loading your PowerShell profile, which avoids running extra startup code. -NonInteractive stops the session from waiting for input; Microsoft says it is meant for scripts that run in scheduled tasks and CI pipelines, and that prompts such as Read-Host then produce errors instead of hanging. If the window stays open because the script is waiting on a prompt, that is the parameter to look at. For more on launching scripts, see how to run a .ps1 PowerShell script.

Do not use this to hide a task you did not create. Hiding the window leaves the task running. Disabling it, after you understand what it does, is the actual fix.

When the command line looks suspicious

Check the command line for these signs before you decide the window is harmless:

  • A very long string after -EncodedCommand. Microsoft describes this parameter as a way to pass commands that need complex quoting, as Base64 in UTF-16LE. It has legitimate uses, but you cannot read the command, so an unexplained one deserves a closer look.
  • A script path in a temporary or download folder, or a file name you cannot match to any software you installed.
  • A task or startup item with a random or blank name that appeared around the time you installed something new.

You can decode an encoded command yourself, which shows what it does without running it. In PowerShell, paste the string between the quotes:

[System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String("PASTE_THE_STRING_HERE"))

If what comes out downloads files or contacts an address you do not recognise, disable the task, run a full scan with Windows Security (Virus & threat protection > Scan options > Full scan), and change the passwords for accounts you used on that PC.

If the window still appears

  • No task or startup item mentions PowerShell. Another program may start it for a moment. Run the Get-CimInstance command repeatedly while the window shows, or check the Details tab in Task Manager and add the Command line column by right-clicking a column header and choosing Select columns.
  • It comes back after you disable the task. Something re-creates it, usually the program that registered it. Uninstall or reconfigure that program, then remove the task.
  • It only appears while you use one app. That app is the launcher. Look in its settings for an option such as automatic updates or background sync.
  • It appears for a fixed number of minutes each time. That points to a task with a repeat interval. Open the task's Triggers tab and check the Repeat task every setting.

If you need the basics of the shell itself, the PowerShell basic commands article covers the cmdlets used above.

Frequently asked questions

Is a PowerShell window that keeps popping up a virus?
Not necessarily. Most of the time a startup app, a scheduled task or a script you installed launches PowerShell to do a small job and the window closes when the job ends. It deserves a malware scan if the command line contains a long encoded string, points to a file you do not recognise, or you cannot trace it to any program you installed.
Can I uninstall PowerShell to stop the window?
No. Windows PowerShell is a built-in part of Windows and other software and Windows tasks rely on it. Remove the thing that launches it instead: the startup entry, scheduled task or script.
Why does the window close by itself after a second?
The command or script finished. A PowerShell window opened with a script file closes when the script ends unless it was started with the -NoExit parameter. A flash that disappears at once usually means a short job that ran and exited.
Does -WindowStyle Hidden fix it?
It only matters if you control the command that starts PowerShell, for example your own scheduled task. Microsoft documents Hidden as one of four valid window styles. For a task you did not create, find and disable the task instead of editing it.

Sources