To run PowerShell from the Command Prompt (CMD), you can use the powershell command. Here are the steps:
1. Open Command Prompt
Press Win + R, type cmd, and press Enter.
2. Run PowerShell
Use one of the following methods:
a) Start PowerShell Interactive Session
To launch PowerShell and switch to its interactive environment:
CMD Copy code
powershell
b) Run a PowerShell Command Directly
To execute a single PowerShell command from CMD:
CMD Copy code
powershell -Command “Write-Host ‘Hello from PowerShell!'”
c) Run a PowerShell Script
To execute a .ps1 script file:
CMD Copy code
powershell -File “C:\Path\To\YourScript.ps1”
3. Exit PowerShell
If you started an interactive session, type the following to return to CMD:
CMD Copy code
exit
Notes:
Ensure PowerShell is installed (it’s included by default on modern Windows versions).
You may need to adjust the execution policy for scripts with Set-ExecutionPolicy if running scripts