Run Powershell Script from CMD - Quick Guide


Run Powershell Script From CMD

Fix Windows errors with Fortect:
Fortect can repair common computer errors by scanning your entire system for damaged or missing OS files and replacing them with the original, working versions. Optimize your PC in 3 simple steps:

  1. Download and Install Fortect on your PC
  2. Use the PC Scan feature to look up any Windows issues (including drivers)
  3. Right-click on Repair, and fix it within a few minutes.

Besides that, it helps you clean up junk files, fix stability problems, and get rid of annoying programs and malware traces.

Do you want to run PowerShell script from CMD because it might not be available on your system? Or do you just want to incorporate PowerShell functionality without rewriting the entire script into a CMD batch file? If your answer is “Yes” to any of these questions, this article will help!

How To Run a PowerShell Script from CMD

  1. Open Command Prompt in Windows with elevated rights from the Start menu by typing CMD and clicking CMD app > Run as administrator.
CMD admin
  1. By default, the CMD console will open in the C:\Windows\System32 folder.
  2. Navigate to the directory of the PowerShell script using the CD command.
  3. For example, I’ve got the PS1 script in drive D, so I run the following command in CMD: cd /d D:
Go to D
  1. Now, execute this command: powershell.exe .\SimplePS.ps1.
Run powershell
  1. Replace .\SimplePS.ps1 with your own PowerShell script file name with the PS extension.
  2. The script should execute within the selected directory as per the underlying codes. If there’s anything to print, you’ll see that on CMD.
  3. For instance, “Hello, this is a simple PowerShell script!” in the current script.
Powershell executed

Expert Tip

When running a PowerShell script on CMD, the process may get interrupted due to the inappropriate settings for the Set-ExecutionPolicy feature.

There are two ways to resolve this error:

Using PowerShell

  1. Right-click on the Start menu icon and choose Windows PowerShell (Admin) from the Power User context menu.
  2. When you see the console, run this command: Set-ExecutionPolicy RemoteSigned.
  3. Hit Enter.
  4. When you see Yes and No prompts, press Y and hit Enter again.
Execution policy

Using CMD

  1. Open CMD with elevated rights.
  2. Copy and paste this command and hit Enter: powershell Set-ExecutionPolicy RemoteSigned.
CMD policy

Related readings:

Now you know how to run a PowerShell script from CMD. This is a quick and convenient way to run advanced scripts on a rudimentary terminal.

Did the article help? Do you know a better way to achieve the same result? Share your thoughts below.

Readers help support MSpoweruser. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help MSPoweruser sustain the editorial team Read more

User forum

0 messages