How can I run a PowerShell script without showing the terminal window?

February 17, 2026 2 answers
Asked by 42plus17
I'm looking to execute a PowerShell script (.ps1) without having the terminal window flash on screen at all. I've tried the -WindowStyle Hidden option, but it still briefly shows the terminal. I want to avoid minimizing the window or utilizing external tools that might pose a security risk. The only effective method I found so far is using VBScript to hide the console, but since VBScript is deprecated by Microsoft, I'm keen on finding an alternative approach. Any suggestions?

Answers

bypass-lane
You can try running your script with `conhost.exe --headless` to suppress the terminal window. Just be cautious, as some Endpoint Detection and Response (EDR) tools might flag this. Here's the command you can use: `conhost.exe --headless powershell.exe -File C:Scriptsmyscript.ps1`. It works well for me!

42plus17: Oh wow, it works. Thank you!

Reply to this answer
does anyone snorkel
If it helps, converting the script to an executable (.exe) is another option to completely suppress the terminal. You can do this using the ps2exe module. Hereโ€™s how: 1. Install the module with `Install-Module -Name ps2exe -Scope CurrentUser`. 2. Then run `Invoke-PS2EXE -InputFile "C:Scriptsscript.ps1" -OutputFile "C:Scriptsscript.exe" -IconFile "C:IconsMailIcon.ico" -NoConsole -Verbose`. Just a heads up, though, this requires creating a custom .exe, which isnโ€™t what youโ€™re looking for but might be a solid workaround!

42plus17: Yes, I wanted to avoid creating a custom exe. I get that many of these tools are C# applications compiled into exe. I'll give your suggestion a shot, or I might just learn enough C# to create my own runner if nothing else works. Thanks!

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions