To run PowerShell 7 from the Command Prompt (cmd.exe), you must first install the PowerShell 7 Core runtime on your system and then type pwsh into the command line. Unlike the built-in Windows PowerShell 5.1, which is launched using the command powershell, PowerShell 7 is a cross-platform version that uses a different executable name to allow both versions to coexist on the same machine without conflict.
What You'll Need
- A computer running Windows 10 or Windows 11.
- An active internet connection to download the installation package.
- Administrative privileges on the PC to install the software and modify system environment variables if necessary.
- The Command Prompt application (cmd.exe), which is pre-installed on all Windows versions.
Step-by-Step
- Download the PowerShell 7 Installer: Visit the official Microsoft GitHub releases page for PowerShell. Look for the latest stable release (marked as "Latest") and download the
.msiinstaller that matches your system architecture. For most modern PCs, this will be the x64 installer. - Run the Installation Wizard: Double-click the downloaded
.msifile. Follow the prompts in the installation wizard. When you reach the "Optional Actions" screen, ensure that the box labeled "Add PowerShell to Path" is checked. This is the most critical step because it tells Windows where thepwsh.exefile is located, allowing you to launch it from any command-line interface without typing the full folder path. - Complete the Setup: Click "Next" and then "Install." If a User Account Control (UAC) prompt appears asking for permission to make changes to your device, click "Yes." Once the installation finishes, click "Finish."
- Open the Command Prompt: Press the Windows key on your keyboard, type
cmd, and press Enter. This opens the traditional black-background Command Prompt window. - Launch PowerShell 7: In the Command Prompt window, type the following command and press Enter:
pwsh - Verify the Version: Once the prompt changes (usually indicated by a different prefix or a welcome message), verify that you are indeed running version 7 by typing:
$PSVersionTable - Check the Output: Look for the line that says "PSVersion." It should show a number starting with 7 (e.g., 7.4.x). If it shows 5.1, you have launched the legacy Windows PowerShell instead of the Core version.
- Exit Back to CMD: When you are finished using PowerShell 7 and want to return to the standard Command Prompt environment, type
exitand press Enter.
Common Mistakes
One of the most frequent errors is typing powershell instead of pwsh. In Windows, the command powershell is hard-coded to launch Windows PowerShell 5.1, which is a separate product built on the .NET Framework. PowerShell 7 is built on .NET (formerly .NET Core) and uses the pwsh executable to avoid overwriting the system-critical legacy version. If you use the wrong command, your scripts may fail if they rely on features only available in version 7.
Another common mistake is ignoring the "Add to Path" checkbox during installation. If this is skipped, typing pwsh in the Command Prompt will result in an error stating that the term is not recognized as a name of a cmdlet, function, script file, or operable program. While this can be fixed manually in the System Environment Variables, it is much simpler to run the installer again and ensure the box is checked.
Users also sometimes confuse the Command Prompt (cmd.exe) with the PowerShell terminal. While you can run PowerShell 7 inside the Command Prompt, they are different shells. If you are already in a PowerShell 5.1 window, typing pwsh will start a "nested" session of PowerShell 7. This means when you type exit, you will drop back into PowerShell 5.1 rather than returning to the desktop or the Command Prompt.
Tips
To make your workflow more efficient, you can launch PowerShell 7 with specific flags directly from the Command Prompt. For example, if you need to run a specific script and then immediately close the session, you can use pwsh -File "C:\scripts\myscript.ps1". This executes the script within the PowerShell 7 engine without requiring you to enter the interactive shell first.
If you find yourself switching between CMD and PowerShell 7 frequently, consider using the Windows Terminal app. Windows Terminal allows you to have multiple tabs open—one for Command Prompt, one for PowerShell 5.1, and one for PowerShell 7—all within a single window. This eliminates the need to manually launch one shell from inside another.
For those who need to run PowerShell 7 with administrative privileges from the Command Prompt, you cannot simply type pwsh if the Command Prompt itself was opened as a standard user. You must right-click the Command Prompt icon and select "Run as administrator" first. Once the elevated CMD window is open, any instance of pwsh started from it will also inherit those administrative permissions.
Troubleshooting
If you type pwsh and receive an error saying the command is not recognized, the installation path is likely missing from your system's environment variables. To fix this without reinstalling, search for "Edit the system environment variables" in the Windows Start menu. Click "Environment Variables," find the "Path" variable under "System variables," and click "Edit." Check if the folder containing pwsh.exe (usually C:\Program Files\PowerShell\7) is listed. If not, click "New" and add the path manually. You must restart the Command Prompt window for this change to take effect.
If PowerShell 7 launches but crashes immediately or throws .NET runtime errors, ensure your Windows updates are current. PowerShell 7 relies on specific runtime components that are often updated via Windows Update. If the issue persists, try downloading the "zip" version of PowerShell 7 from GitHub, extracting it to a folder, and running the pwsh.exe file directly from that folder to see if the installed version is corrupted.
If you encounter a "Script Execution Policy" error when trying to run a script after launching pwsh, this is a security feature of PowerShell. You can bypass this for the current session by launching PowerShell 7 from CMD using the command pwsh -ExecutionPolicy Bypass. This allows the script to run without permanently changing the global security settings of your machine.
Frequently Asked Questions
Is PowerShell 7 the same as Windows PowerShell?
No. Windows PowerShell (versions 5.1 and older) is built on the .NET Framework and is specific to Windows. PowerShell 7 (Core) is built on .NET and is cross-platform, meaning it can run on Windows, macOS, and Linux.
Can I uninstall Windows PowerShell 5.1 to save space?
No, Windows PowerShell 5.1 is a built-in component of the Windows operating system. Attempting to remove it can break system functions and Windows updates. PowerShell 7 is designed to be installed alongside it.
Does running pwsh in CMD slow down my computer?
No. Launching PowerShell 7 from the Command Prompt simply starts a new process. It uses a small amount of additional RAM while the session is active, but it does not impact overall system performance when not in use.
Why would I use CMD to launch PowerShell instead of just opening PowerShell?
Some users prefer the Command Prompt for basic navigation and only need the advanced capabilities of PowerShell 7 for specific tasks. Launching it from CMD allows them to stay in a familiar environment while accessing powerful scripting tools on demand.
Will my old PowerShell scripts work in version 7?
Most scripts will work, but because PowerShell 7 is based on a different version of .NET, some legacy modules specifically designed for Windows PowerShell 5.1 may not be compatible. In these cases, PowerShell 7 uses a compatibility layer to run them in a separate process.
How do I know if I am in CMD or PowerShell?
The Command Prompt usually shows a path ending in a greater-than sign (e.g., C:\Users\Name>). PowerShell 7 typically starts its prompt with PS (e.g., PS C:\Users\Name>).