powershellPowerShell Command: Launch Windows PowerShell | CMD Guide
Learn how to start Windows PowerShell from Command Prompt. Complete guide with syntax, examples, use cases, and tips for IT professionals.
The powershell command is a Windows Command Prompt utility that launches Windows PowerShell, a task-based command-line shell and scripting language built on .NET Framework. Use it to access advanced system administration features, execute scripts, and manage Windows with object-oriented commands that CMD cannot handle.
Whether you're an IT administrator automating server deployments, a developer managing cloud resources, or a power user troubleshooting system issues, PowerShell provides capabilities far beyond traditional Command Prompt. System administrators rely on this command to bridge legacy CMD workflows with modern PowerShell automation, enabling seamless script execution and advanced configuration management without leaving their existing terminal sessions.
This comprehensive guide covers PowerShell command syntax, launch options, practical examples for common scenarios, troubleshooting tips, related commands, and frequently asked questions. By the end, you'll confidently launch PowerShell from CMD and understand when to use each shell for maximum productivity.
What Is the PowerShell Command?
The powershell command is a CMD executable that starts a new Windows PowerShell session within the current Command Prompt window or launches it in a new window. Windows PowerShell is Microsoft's advanced shell that combines traditional command-line functionality with a powerful scripting environment, object-oriented pipeline, and access to .NET Framework libraries.
PowerShell runs on all modern Windows versions (Windows 7 and later), with PowerShell Core (version 6+) also available for Linux and macOS. From CMD, the powershell command provides a quick transition to PowerShell without opening a new application window, making it ideal for hybrid workflows where you need CMD for legacy tasks and PowerShell for modern automation.
Unlike CMD's text-based output, PowerShell works with .NET objects, enabling sophisticated data manipulation, remote management capabilities, and integration with Microsoft cloud services like Azure and Microsoft 365.
Syntax
powershell [options] [-Command <script>] [-File <path>] [-EncodedCommand <base64>]
Parameters and Options
| Parameter | Description |
|---|---|
-Command | Executes the specified PowerShell command or script block |
-File | Runs the specified PowerShell script file (.ps1) |
-NoProfile | Starts PowerShell without loading user profile |
-ExecutionPolicy | Sets execution policy for the session (Bypass, RemoteSigned, etc.) |
-NoExit | Keeps PowerShell window open after running command |
-WindowStyle | Sets window display style (Hidden, Minimized, Maximized, Normal) |
-Version | Specifies PowerShell version to use |
-EncodedCommand | Accepts Base64-encoded command string |
-NoLogo | Starts PowerShell without displaying copyright banner |
Parameters Explained
-Command Option
The -Command parameter executes a single PowerShell command or script block directly from CMD without entering an interactive PowerShell session. This is perfect for one-line automation tasks embedded in batch files.
Example: powershell -Command "Get-Process | Where-Object {$_.CPU -gt 100}"
This command finds all processes using more than 100 CPU units without opening an interactive PowerShell prompt.
-File Option
Use -File to execute a complete PowerShell script file (.ps1). This parameter is essential for running saved automation scripts from CMD or batch files. The script runs in a new PowerShell session that closes automatically when execution completes.
Example: powershell -File "C:\Scripts\Backup.ps1"
-ExecutionPolicy Bypass
PowerShell's execution policy prevents unauthorized script execution. The -ExecutionPolicy Bypass parameter overrides this restriction for the current session only, allowing scripts to run without permanent security changes. IT administrators use this for deployment scripts that need elevated permissions.
Example: powershell -ExecutionPolicy Bypass -File "C:\Deploy\Install.ps1"
-NoProfile Option
Loading PowerShell profiles can slow down startup and introduce unexpected configurations. The -NoProfile switch skips profile loading, ensuring clean, predictable execution—critical for production automation and enterprise deployment scripts.
-WindowStyle Hidden
Runs PowerShell commands or scripts without displaying a window. This option is essential for background automation, scheduled tasks, and silent installations where user interaction should be minimized.
Example: powershell -WindowStyle Hidden -Command "Start-Service MSSQLSERVER"
Examples
Basic Usage: Launch PowerShell
Scenario: You're working in CMD and need to quickly access PowerShell for a task requiring .NET functionality.
powershell
Expected Output:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\Admin>
Explanation: This launches an interactive PowerShell session in the current CMD window. Notice the prompt changes from C:\> to PS C:\>, indicating PowerShell mode. Type exit to return to CMD.
Execute Single PowerShell Command
Scenario: You need to check installed .NET Framework versions from a batch script without entering interactive mode.
powershell -Command "Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse"
Expected Output: Registry entries showing installed .NET versions.
Explanation: The -Command parameter executes the PowerShell cmdlet and returns control to CMD immediately. This pattern is ideal for embedding PowerShell capabilities in batch automation.
Run PowerShell Script File
Scenario: You've created a backup script (Backup-Database.ps1) and need to execute it from CMD during system maintenance.
powershell -ExecutionPolicy Bypass -File "C:\Scripts\Backup-Database.ps1"
Expected Output: Script executes and displays progress/results based on script content.
Explanation: The -ExecutionPolicy Bypass ensures the script runs even if the system policy blocks script execution. The -File parameter specifies the script path.
Launch PowerShell as Administrator from CMD
Scenario: You need elevated privileges for system configuration tasks but started in a non-admin CMD window.
powershell -Command "Start-Process powershell -Verb RunAs"
Expected Output: UAC prompt appears, then a new PowerShell window opens with administrator rights.
Explanation: This uses PowerShell's Start-Process cmdlet with -Verb RunAs to trigger elevation. Useful when you need admin PowerShell from standard CMD.
Silent Background Script Execution
Scenario: You're deploying software via scheduled task and need PowerShell to install applications without user notification.
powershell -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File "C:\Deploy\SilentInstall.ps1"
Expected Output: No visible window; script runs in background.
Explanation: Combines -WindowStyle Hidden (no window), -NoProfile (fast startup), and -ExecutionPolicy Bypass (permission override) for enterprise deployment scenarios.
Execute Remote PowerShell Command
Scenario: You need to restart a service on a remote server using PowerShell remoting from CMD.
powershell -Command "Invoke-Command -ComputerName SERVER01 -ScriptBlock {Restart-Service W3SVC}"
Expected Output: Remote service restart confirmation.
Explanation: Uses PowerShell's remoting capability to execute commands on remote machines. Requires WinRM configuration and appropriate permissions.
Get System Information with PowerShell
Scenario: You need detailed hardware information that CMD's systeminfo doesn't provide in a usable format.
powershell -Command "Get-ComputerInfo | Select-Object CsName, WindowsVersion, OsArchitecture, CsProcessors"
Expected Output: Structured object output showing computer name, Windows version, architecture, and processor details.
Explanation: Demonstrates PowerShell's object-oriented output advantage over CMD's text-based results.
Run PowerShell with Specific Version
Scenario: Your script requires PowerShell 2.0 compatibility for legacy system support.
powershell -Version 2.0 -Command "Get-Host"
Expected Output: PowerShell 2.0 session with version confirmation.
Explanation: Forces use of specific PowerShell version when multiple versions are installed. Critical for maintaining compatibility with older scripts.
Base64 Encoded Command Execution
Scenario: You need to execute a complex PowerShell command with special characters that would break in CMD.
powershell -EncodedCommand RwBlAHQALQBQAHIAbwBjAGUAcwBzAA==
Expected Output: Executes the decoded command (Get-Process).
Explanation: Base64 encoding prevents interpretation issues with special characters, quotes, and pipes. Used in advanced automation and security tools.
Launch PowerShell with No Exit
Scenario: You want to run a configuration script but keep the PowerShell session open for manual verification.
powershell -NoExit -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser"
Expected Output: Execution policy changes, then PowerShell prompt remains open.
Explanation: The -NoExit parameter prevents automatic session closure, allowing you to inspect results or run additional commands.
Common Use Cases
-
Hybrid Script Automation: Launch PowerShell from batch files to combine CMD's simplicity with PowerShell's advanced features for enterprise deployment scripts.
-
One-Line System Queries: Execute single PowerShell commands from CMD to retrieve system information, check service status, or query registry without entering interactive mode.
-
Remote Server Management: Use PowerShell remoting capabilities from CMD to manage Windows servers, restart services, and execute commands across multiple machines simultaneously.
-
Active Directory Administration: Access PowerShell's AD cmdlets from CMD for user provisioning, group management, and organizational unit operations in enterprise environments.
-
Scheduled Task Execution: Call PowerShell scripts from Windows Task Scheduler using CMD wrapper for automated maintenance, backups, and monitoring tasks.
-
Silent Software Deployment: Execute PowerShell installation scripts with hidden windows for enterprise software distribution without user interruption or manual interaction.
-
Cloud Resource Management: Launch PowerShell from CMD to manage Azure resources, Microsoft 365 services, and AWS infrastructure using respective PowerShell modules.
-
Advanced File Operations: Leverage PowerShell's object-oriented file handling from CMD for complex search, filtering, and bulk file manipulation tasks beyond CMD capabilities.
-
Security Auditing: Run PowerShell security cmdlets from batch scripts to check system configurations, audit permissions, and generate compliance reports for IT security teams.
-
Network Configuration: Execute PowerShell networking commands from CMD for advanced TCP/IP configuration, firewall rule management, and network adapter settings that CMD cannot modify.
-
Performance Monitoring: Use PowerShell performance counters and WMI queries from CMD to collect detailed system metrics, analyze resource usage, and troubleshoot performance issues.
-
Exchange and SQL Management: Access PowerShell management shells for Exchange Server and SQL Server from CMD for database administration and email system configuration tasks.
Tips and Best Practices
-
Use -NoProfile for Scripts: Always include
-NoProfilein production automation scripts to prevent user profile configurations from interfering with script execution. This ensures consistent behavior across different machines and user accounts. -
Specify Execution Policy Explicitly: Include
-ExecutionPolicy Bypassor-ExecutionPolicy RemoteSignedwhen running scripts to avoid execution policy errors. This prevents failures in restrictive environments without permanently changing system security settings. -
Prefer -File Over -Command for Scripts: Use
-Fileinstead of-Commandwhen executing script files. The-Fileparameter provides better error handling, parameter passing, and maintains script scope properly compared to command execution. -
Quote Paths with Spaces: Always wrap file paths containing spaces in double quotes:
powershell -File "C:\Program Files\Scripts\Backup.ps1". Unquoted paths will cause parsing errors and script failure. -
Use -WindowStyle Hidden for Background Tasks: For scheduled tasks and silent operations, combine
-WindowStyle Hiddenwith-NoProfileto minimize resource usage and prevent user distraction during automated maintenance windows. -
Avoid -EncodedCommand Unless Necessary: Base64 encoding makes debugging difficult. Only use
-EncodedCommandwhen handling commands with complex quoting, special characters, or when obfuscation is required for security tools. -
Test in PowerShell First: Before embedding PowerShell commands in batch files, test them directly in a PowerShell session. This simplifies troubleshooting and ensures syntax correctness before automation.
-
Use Full Cmdlet Names in Scripts: Avoid PowerShell aliases (like
gciforGet-ChildItem) in production scripts launched from CMD. Full cmdlet names improve readability and prevent alias conflicts across PowerShell versions. -
Log Script Output: Redirect PowerShell output to log files for audit trails:
powershell -File script.ps1 > C:\Logs\output.log 2>&1. This captures both standard output and errors for troubleshooting and compliance. -
Check Exit Codes: PowerShell returns exit codes to CMD. Capture them with
%ERRORLEVEL%in batch files to implement proper error handling and conditional logic based on script success or failure. -
Use -NoLogo for Clean Output: Add
-NoLogoto suppress the PowerShell copyright banner when capturing output for parsing or when running multiple sequential commands where the banner creates unnecessary noise. -
Version Compatibility: When deploying to mixed environments, specify
-Versionto ensure script compatibility. Legacy systems may only support PowerShell 2.0, while modern scripts require 5.1 or PowerShell Core 7+.
Troubleshooting Common Issues
"Running Scripts is Disabled on This System"
Problem: You execute powershell -File script.ps1 and receive an execution policy error blocking script execution.
Cause: Windows default execution policy is "Restricted," preventing any script execution for security. This affects all .ps1 files regardless of source.
Solution: Use -ExecutionPolicy Bypass to override for the current session:
powershell -ExecutionPolicy Bypass -File script.ps1
Prevention: For permanent changes (requires admin rights), set execution policy to RemoteSigned: Set-ExecutionPolicy RemoteSigned -Scope LocalMachine in an admin PowerShell session.
PowerShell Command Not Found or Not Recognized
Problem: CMD returns "'powershell' is not recognized as an internal or external command."
Cause: PowerShell is not installed (rare on modern Windows) or the PATH environment variable is corrupted and doesn't include C:\Windows\System32.
Solution: Use the full path to PowerShell:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Prevention: Verify and repair PATH variable in System Properties > Environment Variables. PowerShell should be in C:\Windows\System32 which is typically in PATH by default.
Script Parameters Not Passing Correctly
Problem: PowerShell script receives incorrect or missing parameters when launched from CMD with powershell -File script.ps1 param1 param2.
Cause: Special characters, spaces, or quotes in parameters are interpreted by CMD before reaching PowerShell, causing parsing errors.
Solution: Wrap the entire command including parameters in quotes and use -Command with proper escaping:
powershell -Command "& 'C:\Scripts\script.ps1' -Param1 'value 1' -Param2 'value 2'"
Prevention: Design scripts to accept named parameters and always use -Parameter Value syntax for clarity and reliability in automated scenarios.
PowerShell Window Closes Immediately
Problem: You launch PowerShell from CMD to run a script, but the window closes before you can read the output or errors.
Cause: PowerShell exits automatically when script execution completes, especially when launched with -File. Error output may not be visible.
Solution: Add -NoExit to keep the session open:
powershell -NoExit -File script.ps1
Or redirect output to a file: powershell -File script.ps1 > output.log 2>&1
Prevention: In scripts, add Read-Host "Press Enter to continue" at the end to pause before exit, or use proper logging for production environments.
Permission Denied or Access Errors
Problem: PowerShell commands launched from CMD fail with "Access is denied" when attempting system operations or file modifications.
Cause: CMD session lacks administrator privileges. Many PowerShell operations require elevation for system-level tasks.
Solution: Launch CMD as administrator first, or use this command to elevate PowerShell from standard CMD:
powershell -Command "Start-Process powershell -Verb RunAs -ArgumentList '-File C:\Scripts\admin-script.ps1'"
Prevention: Always run deployment and system configuration scripts from elevated CMD/PowerShell sessions. Document admin requirements in script headers.
Slow PowerShell Startup from CMD
Problem: Launching PowerShell from CMD takes 10-30 seconds, causing batch script delays and timeout issues in automation.
Cause: PowerShell loads user profile, modules, and executes profile scripts on startup. Large profiles or network-mapped profile paths cause significant delays.
Solution: Use -NoProfile to skip profile loading:
powershell -NoProfile -Command "Get-Service"
Prevention: Optimize PowerShell profiles by removing unnecessary module imports and moving heavy initialization to on-demand loading. Use -NoProfile in all production automation scripts.
Related Commands
cmd – Traditional Command Prompt
The legacy Windows shell that powershell command launches from. Use CMD for simple file operations, batch scripting, and legacy system compatibility. Switch to PowerShell when you need object-oriented output, remote management, or .NET Framework access.
When to use CMD: Simple file copies, directory navigation, running legacy batch files, or when PowerShell is unavailable on older systems.
pwsh – PowerShell Core
The cross-platform successor to Windows PowerShell, available on Linux and macOS. Launch with pwsh instead of powershell for modern .NET Core features and side-by-side installation with Windows PowerShell 5.1.
When to use pwsh: Cross-platform scripts, modern .NET Core features, or when targeting PowerShell 7+ functionality. Note that pwsh requires separate installation.
wmic – Windows Management Instrumentation
Legacy command-line tool for querying system information and management tasks. PowerShell's Get-WmiObject and Get-CimInstance cmdlets provide the same functionality with better output formatting and scripting capabilities.
When to use wmic: Quick one-line system queries on systems without PowerShell access, or in legacy environments where PowerShell is restricted by policy.
runas – Run As Different User
Executes commands with different user credentials. PowerShell offers Start-Process -Credential for more flexible credential handling and better integration with automated workflows.
When to use runas: When you need to run CMD or GUI applications as a different user. Use PowerShell's -Credential parameter for script-based authentication.
schtasks – Schedule Tasks
Creates and manages scheduled tasks from CMD. PowerShell's New-ScheduledTask and related cmdlets provide more granular control over trigger conditions, actions, and task settings.
When to use schtasks: Creating simple scheduled tasks from batch files. Use PowerShell's task scheduling cmdlets for complex enterprise automation requiring advanced trigger logic.
reg – Registry Editor
Command-line registry manipulation tool. PowerShell's registry provider (HKLM:\, HKCU:\) allows treating the registry like a file system with object-oriented cmdlets for safer and more flexible registry operations.
When to use reg: Quick registry queries in batch files. Use PowerShell's Get-ItemProperty and Set-ItemProperty for script-based registry modifications with better error handling.
Frequently Asked Questions
What is the difference between powershell and cmd?
PowerShell is an object-oriented shell built on .NET Framework with advanced scripting capabilities, while CMD is a text-based legacy shell. PowerShell cmdlets output .NET objects enabling sophisticated data manipulation, whereas CMD commands return plain text requiring parsing. Use PowerShell for automation, remote management, and modern Windows administration; use CMD for simple tasks and legacy batch script compatibility.
How do I run PowerShell as administrator from Command Prompt?
Use powershell -Command "Start-Process powershell -Verb RunAs" to launch an elevated PowerShell window with administrator privileges. The -Verb RunAs parameter triggers User Account Control (UAC) prompting for elevation. Alternatively, launch CMD as administrator first, then any powershell command will inherit admin rights automatically.
Can I run PowerShell scripts from batch files?
Yes, embed PowerShell commands in batch files using powershell -ExecutionPolicy Bypass -File "path\to\script.ps1". This allows combining CMD's batch processing with PowerShell's advanced capabilities. Always include -ExecutionPolicy Bypass to prevent script execution policy errors in enterprise environments where default policies restrict script execution.
Why does PowerShell say scripts are disabled?
Windows sets the default PowerShell execution policy to "Restricted" for security, blocking all script execution. Override this for individual commands with -ExecutionPolicy Bypass parameter, or permanently change policy (requires admin) with Set-ExecutionPolicy RemoteSigned. The RemoteSigned policy allows local scripts while requiring signatures for downloaded scripts.
How do I pass parameters to PowerShell scripts from CMD?
Use -File parameter followed by script path and named parameters: powershell -File script.ps1 -Param1 "value1" -Param2 "value2". Always use named parameters instead of positional ones for clarity and reliability. Enclose values with spaces in quotes to prevent CMD from splitting them into multiple arguments.
What is the difference between -Command and -File parameters?
-Command executes PowerShell code directly as a string, ideal for single-line operations: powershell -Command "Get-Process". -File executes saved .ps1 script files with proper scope and better parameter handling: powershell -File script.ps1. Use -File for script execution and -Command for embedding quick PowerShell operations in batch files or when script source is dynamically generated.
Can PowerShell run on older Windows versions?
PowerShell 2.0 comes pre-installed on Windows 7 and Server 2008 R2. PowerShell 5.1 is the final version for Windows PowerShell (included in Windows 10/11 and Server 2016+). PowerShell Core 6+ runs on Windows 7 SP1 and later but requires separate installation. Check your version with powershell -Command "$PSVersionTable.PSVersion".
How do I hide PowerShell window when running scripts?
Use -WindowStyle Hidden parameter to run scripts without displaying a window: powershell -WindowStyle Hidden -File script.ps1. This is essential for background tasks, scheduled jobs, and enterprise deployment scenarios where user notification is unnecessary. Combine with output redirection to capture results: > log.txt 2>&1.
Why is PowerShell startup so slow from CMD?
PowerShell loads user profiles and modules on startup, which can take 10-30 seconds on network profiles or with heavy customization. Add -NoProfile parameter to skip profile loading: powershell -NoProfile -Command "Get-Service". This reduces startup time to under 2 seconds in most cases and ensures consistent behavior across different user accounts.
Can I run PowerShell commands remotely from CMD?
Yes, use powershell -Command "Invoke-Command -ComputerName SERVER01 -ScriptBlock {command}" to execute PowerShell commands on remote machines. This requires WinRM service enabled on target systems and appropriate network firewall rules. For multiple servers, use comma-separated computer names: -ComputerName SERVER01,SERVER02,SERVER03.
How do I troubleshoot PowerShell command errors in batch files?
Add output redirection to capture errors: powershell -File script.ps1 > output.log 2>&1. Check exit codes with echo %ERRORLEVEL% immediately after PowerShell execution (0 indicates success). Use -NoProfile and -ExecutionPolicy Bypass to eliminate common startup issues. Test PowerShell commands interactively first before embedding in batch automation.
What encoding should I use for PowerShell scripts?
Save PowerShell scripts (.ps1 files) as UTF-8 with BOM (Byte Order Mark) for maximum compatibility across PowerShell versions. Windows PowerShell 5.1 and earlier default to ANSI encoding which causes issues with special characters. PowerShell Core 7+ handles UTF-8 without BOM correctly. Most modern editors (VS Code, PowerShell ISE) default to UTF-8 with BOM automatically.
Quick Reference Card
| Command | Purpose | Example |
|---|---|---|
powershell | Launch interactive PowerShell session | Quick access to PowerShell from CMD |
powershell -Command "cmdlet" | Execute single PowerShell command | powershell -Command "Get-Process" |
powershell -File script.ps1 | Run PowerShell script file | Execute saved automation scripts |
powershell -NoProfile | Start without loading user profile | Fast startup for automation |
powershell -ExecutionPolicy Bypass | Override script execution restrictions | Enable script execution temporarily |
powershell -WindowStyle Hidden | Run script without visible window | Background/silent operations |
powershell -NoExit -Command "cmd" | Keep session open after command | Inspect results after execution |
powershell -Command "Start-Process powershell -Verb RunAs" | Launch as administrator | Elevate privileges from standard CMD |
Try PowerShell in Our Simulator
Ready to practice PowerShell commands in a risk-free environment? Use our interactive Windows Command Simulator to experiment with PowerShell and other CMD commands without affecting your system. Perfect for learning, testing scripts, and mastering command-line workflows.
Explore our complete Windows Commands Reference for detailed documentation on 200+ CMD and PowerShell commands, including syntax, examples, and use cases for system administration and automation.
Summary
The powershell command bridges the gap between traditional Command Prompt and modern Windows PowerShell, enabling IT professionals to access advanced scripting capabilities, object-oriented output, and .NET Framework features directly from CMD. Whether launching interactive sessions, executing one-line commands with -Command, or running complex automation scripts with -File, this command is essential for hybrid workflows that combine legacy batch processing with contemporary PowerShell automation.
Key parameters like -ExecutionPolicy Bypass solve permission restrictions, -NoProfile accelerates startup in production environments, and -WindowStyle Hidden enables silent background operations for enterprise deployment scenarios. Understanding when to use -Command versus -File, how to pass parameters correctly, and the importance of proper error handling separates basic PowerShell usage from professional system administration practices.
Most importantly, PowerShell from CMD empowers system administrators to leverage object-oriented data manipulation, remote management capabilities, and extensive .NET libraries while maintaining compatibility with existing batch scripts and CMD-based automation tools. The ability to embed PowerShell commands in batch files creates powerful hybrid solutions that combine the best features of both shells.
Master the PowerShell command to unlock Windows automation potential, streamline system administration tasks, and build robust deployment scripts that scale across enterprise environments. Practice these techniques in safe environments first, always test with -NoProfile to ensure consistency, and document execution policy requirements for team collaboration and future maintenance.