System command

powershell command

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. This guide lists the documented syntax and parameters for powershell; check Microsoft Learn for version, role and execution-context requirements.

Availability: Microsoft Learn command reference spanning Windows client and Windows Server releases; some entries are legacy, role-specific, optional-feature or interactive subcommands.中文

Documented syntax

PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>] [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive] [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}] [-WindowStyle <style>] [-EncodedArguments <Base64EncodedArguments>] [-EncodedCommand <Base64EncodedCommand>] [-ConfigurationName <string>] [-File - | <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>] [-Command - | { <script-block> [-args <arg-array>] } | { <string> [<CommandParameters>] }]
PowerShell[.exe] -Help | -? | /?

The linked Microsoft Learn article is the upstream authority. Availability may depend on Windows release, role, optional feature or interactive tool context.

Examples

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

PowerShell.exe -NoProfile

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

PowerShell.exe -ExecutionPolicy RemoteSigned -File .\script.ps1

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

PowerShell.exe -Command "Get-Date"

Parameters, options and clauses

Option / clauseDescription
-PSConsoleFile <file>Load the specified Windows PowerShell console file.
-Version <version>Start the specified Windows PowerShell version where installed.
-NoLogoHide the copyright banner at startup.
-NoExitKeep the shell open after startup commands finish.
-Sta / -MtaChoose single-threaded or multithreaded apartment mode.
-NoProfileDo not load PowerShell profiles.
-NonInteractiveDo not present interactive prompts.
-InputFormat {Text|XML}Choose the format for input data.
-OutputFormat {Text|XML}Choose the format for output data.
-WindowStyle <style>Set the PowerShell window style.
-EncodedArguments <Base64EncodedArguments>Pass command-line arguments encoded as Base64.
-EncodedCommand <Base64EncodedCommand>Run a Base64-encoded command string.
-ConfigurationName <string>Connect to the specified session configuration.
-File <filePath> <args>Run a script file with optional arguments; use - to read from standard input.
-ExecutionPolicy <ExecutionPolicy>Set the process execution policy; group policy and other scopes can take precedence.
-Command <script-block|string>Run a command or script block and then exit unless -NoExit is specified.
-Help / -? / ?Display command-line help.
-Command - | <script-block> | <string>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/?Display command help or the supported command-line usage.
<script-block>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
-argsMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
<arg-array>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<CommandParameters>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory