Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.
PowerShell.exe -NoProfileWindows 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.
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.
Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.
PowerShell.exe -NoProfileExample from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.
PowerShell.exe -ExecutionPolicy RemoteSigned -File .\script.ps1Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.
PowerShell.exe -Command "Get-Date"| Option / clause | Description |
|---|---|
-PSConsoleFile <file> | Load the specified Windows PowerShell console file. |
-Version <version> | Start the specified Windows PowerShell version where installed. |
-NoLogo | Hide the copyright banner at startup. |
-NoExit | Keep the shell open after startup commands finish. |
-Sta / -Mta | Choose single-threaded or multithreaded apartment mode. |
-NoProfile | Do not load PowerShell profiles. |
-NonInteractive | Do 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. |
-args | Microsoft 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. |
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.