-file | -f | Specify a script to be run by the Powershell interpreter. Value can be - which reads the «script» from stdin. Possibly to be combined with -noExit . |
-command | -c | Specify a command to be executed, then exit (unless -noExit is specified). Value can be a string, a script block or - . (See also Executing a PowerShell script in a cmd.exe batch file) |
-configurationName | -config | Specify configuration endpoint in which PowerShell is run. |
-customPipeName | | Name for an additional IPC server (named pipe), used for debugging or other cross-process communication. |
-encodedCommand | -e , -ec | Command is Base64 encoded. |
-executionPolicy | -ex , -ep | Sets the execution policy (which is stored in the environment variable $env:psExecutionPolicyPreference .) |
-inputFormat | -inp , -if | Description of data format that is sent to PowerShell. Possible values: text or xml (which is serliazed CLIXML format). |
-interactive | -i | Opens an interactive PowerShell session. (See also -nonInteractive ) |
-login | -l | Starts PowerShell as a login shell using /bin/sh . Only useful on Linux and macOS. Must be first parameter when used. |
-MTA , -STA | | Start the shell using a multi-threaded/single-threaded apartment. Windows only. Defaults to -STA if not specified |
-noExit | -noe | Do not exit after running startup commands. |
-noLogo | -nol | Do not show copyright banner at startup. Without -noLogo , PowerShell displays a copyright banner and, if executing the profile takes longer than 500 ms(?), it also prints Loading personal and system profiles took xyz ms. |
-nonInteractive | -noni | Non-interactive prompt |
-noProfile | -nop | Do not load the PowerShell profile. (see the automatic variable $profile ). |
-outputFormat | -o , -of | Specifies output format. Possible valueare text and XML (serialized CLIXML format). |
-settingsFile | -settings | Overrides system-wide powershell.config.json file (which, by default, is tored in the directory that is pointed at by $psHome ) |
-version | -v | Show used version of PowerShell. See also the automatic variable $psVersionTable . |
-windowStyle | -w | Window style for the session. Possible values are normal , minimized , maximized and hidden . |
-workingDirectory | -wd | Sets the initial working directory by executing set-location -literalPath … . (This parameter Seems to be available in PowerShell Core only) |
-help | -? , /? | Show help |
Default option
If PowerShell is invoked with no options (but values are present in the command line), the default options for PowerShell 5.1 (powershell.exe
) is -file
and -command
for Powershell 7 (pwsh.exe
).
This change was necessary when PowerShell was ported to Unix like environments in order to support shebang lines.
-noExit
When using -c
, the new PowerShell session is terminated when it has finished evaluating the statements. This termination can be prevented by using the -noExit
parameter instead of the -c
parameter:
PS C:\> $PID
95420
PS C:\> pwsh -c '$PID'
87390
PS C:\> $PID
95420
PS C:\> pwsh -noExit '$PID'
14464
PS C:\> $PID
14464
PS C:\> exit
PS C:\> $PID
95420