Check command line used to launch a PowerShell session

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() 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish