Check command line used to launch a PowerShell session

Check the command used to launch a PowerShell session.

John Savill

May 6, 2016

1 Min Read
Check command line used to launch a PowerShell session

Q. How can I check the exact command line used to launch a PowerShell instance?

A. It can sometimes be useful to know the exact parameters used to launch PowerShell, for example was -NOPROFILE used. There are a number of methods to check how PowerShell was launched. I typically use:

gwmi Win32_Process CommandLine -filter "ProcessId = $PID" | % CommandLine

If you just wanted to check on the arguments used you could use:

[System.Environment]::GetCommandLineArgs() 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like