To use PowerShell from Command Prompt, simply type powershell and press Enter to launch the PowerShell session directly within the CMD window. This allows you to run PowerShell commands without leaving the Command Prompt interface, useful for quick scripting or accessing PowerShell features in a familiar environment.

What You'll Need

  • A Windows operating system (Windows 7 or later, with PowerShell preinstalled)
  • Access to Command Prompt (no admin rights required for basic use)
  • Basic familiarity with typing commands in a terminal

Step-by-Step

  1. Open Command Prompt by pressing Win + R, typing cmd, and pressing Enter.
  2. In the Command Prompt window, type powershell and press Enter.
  3. Observe the prompt change from C:\> to PS C:\>, indicating you are now in a PowerShell session.
  4. To run a PowerShell command, type it directly (e.g., Get-Process) and press Enter.
  5. To return to Command Prompt, type exit and press Enter.
  6. To run a single PowerShell command without staying in the session, use powershell -Command "Get-Date" and press Enter.
  7. To run a PowerShell script file, use powershell -ExecutionPolicy Bypass -File "C:\script.ps1" (adjust path as needed).
  8. To view available PowerShell versions, type powershell -Version in Command Prompt.
  9. To check if PowerShell is installed, type where powershell in Command Prompt; it should return a path like C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.

Common Mistakes

  • Forgetting to quote strings with spaces in -Command arguments, causing parsing errors.
  • Assuming PowerShell commands work identically in CMD; some syntax (like aliases) may not transfer.
  • Not realizing that exit only leaves the PowerShell subsession, not Command Prompt itself.
  • Using outdated execution policies that block scripts without realizing -ExecutionPolicy Bypass is needed for testing.
  • Confusing powershell (the executable) with powershell.exe (redundant but valid) or pwsh (PowerShell Core, which may not be present).

Tips

  • Use powershell -NoLogo to suppress the version banner when embedding in scripts or automation.
  • For persistent access, create a shortcut that runs cmd /k powershell to start CMD and immediately enter PowerShell.
  • Combine with CMD operators: ipconfig | powershell -Command "$_ -match 'IPv4'" to filter output using PowerShell.
  • Use Start-Process powershell from within CMD to launch a new PowerShell window.
  • To avoid typing full paths, add PowerShell to your system PATH if it isn’t already (it is by default on modern Windows).
  • When troubleshooting, prepend commands with echo in PowerShell to debug variable values.

Troubleshooting

  • Command not recognized: Ensure you’re typing powershell correctly and that System32 is in your PATH. Try the full path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.
  • Access denied or execution policy error: Use -ExecutionPolicy Bypass as a temporary fix. For a more permanent solution, run Set-ExecutionPolicy RemoteSigned in PowerShell (requires admin).
  • No response after typing powershell: Wait a few moments; PowerShell may take time to load on older systems. Check Task Manager for powershell.exe.
  • Wrong version launching: If you have both Windows PowerShell and PowerShell Core installed, use pwsh for Core or the full path to select a specific version.
  • Script won’t run: Verify the file exists, the path is correct (use quotes around paths with spaces), and that you’re allowed to run scripts (check execution policy).

Frequently Asked Questions

Can I run PowerShell commands directly in Command Prompt without switching?

Yes, by using powershell -Command "<command>" you can execute a single PowerShell command and return to CMD immediately.

Is PowerShell available on all versions of Windows?

PowerShell is built into Windows 7 SP1 and later. Windows 7 and 8 may require an update, but it is present by default on Windows 10 and 11.

What’s the difference between typing powershell and pwsh in CMD?

powershell launches Windows PowerShell (version 5.1), while pwsh launches PowerShell Core (6+), which must be installed separately and is not included by default on Windows.

Do I need administrator rights to use PowerShell from Command Prompt?

No, for basic use and user-scoped commands. Administrative privileges are only needed for system-wide changes like modifying execution policy or accessing protected registry keys.

Can I use Command Prompt and PowerShell in the same batch file?

Yes, you can alternate between them by calling powershell to run commands or scripts, then resuming CMD commands after exit returns.

Why does my PowerShell script fail when run from CMD but work in the PowerShell IDE?

This is often due to execution policy restrictions or path issues. Ensure you’re using -ExecutionPolicy Bypass and that all file paths are absolute or correctly relative to the CMD working directory.