Launch a PowerShell session.

      powershell[.exe] [-PSConsoleFile file | -Version version]
         [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
            [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
               [-WindowStyle Style] [EncodedCommand Base64EncodedCommand]
                  [-File FilePath Args] [-ExecutionPolicy ExecutionPolicy]
                     [-Command { - | script-block [-args arg-array]
                                   | string [CommandParameters] } ]

      powershell[.exe] -Help | -? | /?
   -PSConsole File   Load a PowerShell console file. (created with export-console)

   -Version          Start the specified version of Windows PowerShell.

   -NoLogo           Hide the copyright banner at startup.

   -NoExit           Do not exit after running startup commands.

   -Sta              Start the shell using a single threaded apartment

   -Mta              Start the shell using a multi-threaded apartment

   -NoProfile        Do not use the user profile.

   -Noninteractive   Don't present an interactive prompt to the user.

   -InputFormat      Format of data sent to Windows PowerShell. Valid values are
                     "Text" (string) or "XML" (serialized CLIXML format). 

   -OutputFormat     Format the output. Valid values are "Text" (string)
                     or "XML" (serialized CLIXML format).

   -Command          Execute commands or a script file of commands 
                     If Command is "-", the command text is read from standard input.

   -WindowStyle      Set the window style to Normal, Minimised, Maximised or Hidden.

   -EncodedCommand   Accepts a base-64 encoded string version of a command, Use this to
                     submit commands to PowerShell that require complex quotation marks
                     or curly braces.

   -File             Execute a script file.

   -ExecutionPolicy  Set the default execution policy for the session.

   -Command          Execute the specified commands (and any parameters) as though they
                     were typed at the PowerShell prompt, and then exit, unless NoExit is specified.
                     The value of Command can be "-", a string. or a script block.

                     If the value of Command is "-", the command is read from standard input.

                     Script blocks must be enclosed in braces ({}).
                     Specify a script block only when running PowerShell.exe from PowerShell.

                     The results of the script are returned to the parent shell as
                     deserialized XML objects, not live objects.

                     If the value of Command is a string, it must be the last parameter
                     in the command , any characters typed after command are interpreted
                     as the command arguments.

                     To write a string that runs a PowerShell command, use the format:

                     "& {command}"

                     where the quotation marks indicate a string and the call operator (&)
                     causes the command to be executed.

   -Help, -?, /?     Display Help

Standard Aliases for Powershell_ISE.exe: ise

When launching a .ps1 script you may wish to specify -noprofile to make sure that the script runs in a default PowerShell environment and does not load any profile scripts.

In Windows Explorer, you can type "powershell" in the address bar to open a PowerShell prompt at the current location.

If you are launching PowerShell from a CMD shell and passing a command that includes any special characters (such as '%') then you will have to apply a suitable CMD escape character e.g. %%

By default, running PowerShell will launch a 64 bit process (C:\Windows\system32\PowerShell.exe)
if you run a 32 bit shell (such as C:\windows\syswow64\cmd.exe) and then try to launch PowerShell, you will launch the 32 bit version (C:\Windows\SysWOW64\WindowsPowerShell\v1.0\PowerShell.exe)

Exit Codes

In PowerShell the exit code is stored in the automatic variable $LASTEXITCODE.

To read exit codes (other than 0 or 1) launch the PowerShell script and return the $LASTEXITCODE in a single line like this:

powershell.exe -noprofile C:\scripts\script.ps1; exit $LASTEXITCODE


Load a console and run a Script:

PowerShell.exe -PSConsoleFile "C:\scripting\MyShell.psc1" -Command ". 'MyScript.ps1'"

Run a Script As Admin:

powershell.exe -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile -file MyScript.ps1' -verb RunAs}"

Run a command to display the security event log:

powershell.exe -command {get-eventlog -logname security}

Run a simple calculation and return (supports Long numbers):

powershell.exe 200000000*2

Or the same thing but calling PowerShell from the CMD shell:

powershell.exe -command "& {get-eventlog -logname security}"

PS.cmd - a simple batch file to launch PowerShell with less typing:
@echo off
Powershell.exe %1

“If you want to launch big ships you have to go where the water is deep” ~ Anon


List of all PowerShell cmdlets
Equivalent bash command: bash - launch bash shell

© Copyright SS64.com 1999-2017
Some rights reserved