run powershell from cmd

Run PowerShell from CMD: Step‑by‑Step Guide

By Hannah Garcia
AD

Running PowerShell from the Command Prompt is a common requirement for system administrators and developers who need to leverage the strengths of both command-line environments. This process is straightforward, yet understanding the nuances ensures a smooth integration of script-based automation with legacy batch workflows. The ability to transition between cmd and PowerShell without friction is a valuable skill for managing Windows infrastructure efficiently.

Why Execute PowerShell from Cmd

The coexistence of Command Prompt and PowerShell stems from their distinct design purposes. Cmd remains the traditional shell for simple file operations and legacy batch scripts, while PowerShell offers a robust object-oriented framework for complex system administration. The need to run PowerShell from cmd usually arises when a user is already deep in a terminal session and needs to execute a specific cmdlet or script that is only available or more efficient in the newer environment. This interoperability prevents the need to close one terminal and open another, streamlining the workflow.

Method 1: The Direct Call

The most direct method to invoke PowerShell is to call the executable file from the command line. This approach launches a new PowerShell session, runs the specified command, and then exits, returning you to the cmd prompt. It is ideal for executing single commands without lingering in the PowerShell environment.

AD
PowerShell vs CMD: Key Differences, Uses & Beginner Guide
PowerShell vs CMD: Key Differences, Uses & Beginner Guide
Difference Between PowerShell and CMD
Difference Between PowerShell and CMD
Difference Between PowerShell and CMD
Difference Between PowerShell and CMD
  • Open Command Prompt (cmd.exe).
  • Type the full path to the PowerShell executable followed by the required execution parameters.
  • Press Enter to execute the command line within the PowerShell runtime.

Execution Commands and Parameters

PowerShell provides specific parameters that dictate how the command is processed. The -Command parameter is used for running non-script blocks, while -File is necessary when you want to execute an entire script file stored on disk. Choosing the correct parameter ensures that the command string is parsed correctly by the PowerShell engine.

Parameter Usage Description Example
-Command Executes one or more commands as a string. powershell -Command "Get-Process"
-File Runs a script file located at a specific path. powershell -File C:\Scripts\script.ps1
-NoProfile Launches without loading the user profile, speeding up execution. powershell -NoProfile -Command "<command>"

Practical Examples

To see the list of running processes using the direct call, you would open cmd and type a specific string targeting the PowerShell executable. For more complex tasks involving scripts, you would point the command to the location of your .ps1 file. These examples highlight the flexibility of triggering a managed runtime from a native console.

Cool Stuff about PowerShell 5.0 in Windows 10 - Scripting Blog [archived]
Cool Stuff about PowerShell 5.0 in Windows 10 - Scripting Blog [archived]
Run CMD, PowerShell or Regedit as SYSTEM in Windows 11
Run CMD, PowerShell or Regedit as SYSTEM in Windows 11
a keyboard with the words powershell and cmd next to each other on it
a keyboard with the words powershell and cmd next to each other on it
  • powershell -Command "Get-Service"
  • powershell -NoProfile -Command "$env:PATH"
  • powershell -File "C:\Utilities\Backup.ps1"

Handling Execution Policy Restrictions

A common obstacle when attempting to run PowerShell from cmd is the execution policy, which is a security feature that determines which scripts are allowed to run. By default, systems often restrict script execution to prevent malicious code. When this policy blocks your command, you must override it temporarily using the -ExecutionPolicy parameter to avoid frustrating errors.

Setting the Bypass execution policy is the standard method for allowing immediate execution of commands without altering the machine's local security settings. This parameter effectively tells PowerShell to ignore the current policy for that specific session, which is safe when running trusted commands from the command line.

AD

Piping and Redirection Between Environments

Advanced usage involves passing data between cmd and PowerShell. While direct piping of objects is not possible due to the difference in how they handle data (text vs. objects), you can redirect standard output. This allows you to use cmd filters like find or more on the text output generated by PowerShell commands. This technique is useful for integrating PowerShell data into traditional text-processing pipelines.

a table that has some different types of words on it, including the names and abbreviations
a table that has some different types of words on it, including the names and abbreviations
an image of a computer screen with the program running on it's desktop monitor
an image of a computer screen with the program running on it's desktop monitor
Download Free PowerShell Quick Reference Guides from Microsoft
Download Free PowerShell Quick Reference Guides from Microsoft
PowerShell Commands: 10-Minute Cheat Sheet Every Windows User Needs
PowerShell Commands: 10-Minute Cheat Sheet Every Windows User Needs
an old computer screen with the text cmd your computer
an old computer screen with the text cmd your computer
6 Basic PowerShell Commands to Get More out of Windows
6 Basic PowerShell Commands to Get More out of Windows

For instance, you can generate a list of services and filter the results using cmd utilities to find specific entries. This creates a hybrid workflow where PowerShell handles the data retrieval, and cmd handles the text manipulation.

the power shell sheet is shown with instructions for how to use it and what to use it
the power shell sheet is shown with instructions for how to use it and what to use it
PowerShell isn't scary—these everyday commands prove it
PowerShell isn't scary—these everyday commands prove it
a blue and white arrow symbol on a black background
a blue and white arrow symbol on a black background
Powershell : The Ultimate Beginner'S Guide To Powershell, Making You A Master At Windows Powershell Command Line Fast! - 9781925989847
Powershell : The Ultimate Beginner'S Guide To Powershell, Making You A Master At Windows Powershell Command Line Fast! - 9781925989847
20 Windows PowerShell Commands You Must Know
20 Windows PowerShell Commands You Must Know
Command Prompt commands and their equivalent command for PowerShell
Command Prompt commands and their equivalent command for PowerShell
Windows PowerShell: Everything You Need to Know
Windows PowerShell: Everything You Need to Know
Find Windows Public IP Address From PowerShell and CMD
Find Windows Public IP Address From PowerShell and CMD
PowerShell: Getting Started - Utilizing the Web: Part 2 (Invoke-RestMethod)
PowerShell: Getting Started - Utilizing the Web: Part 2 (Invoke-RestMethod)
Windows Kommandoer: Komplet Cheat Sheet med CMD, PowerShell & Run (2025)
Windows Kommandoer: Komplet Cheat Sheet med CMD, PowerShell & Run (2025)
cmd and powershell command
cmd and powershell command
Mastering Polly Retry, Starting PowerShell from CMD, and Storybook Design for Developers
Mastering Polly Retry, Starting PowerShell from CMD, and Storybook Design for Developers
AD