Powershell

How to Run PowerShell in CMD

PowerShell commands or scripts can be executed using the PowerShell console. However, as a Windows user, you may not know that you can also run them using other command line tools such as CMD. The Command Prompt is an interpreter that lets you execute commands. PowerShell interface and working can be emulated inside the CMD using a specific command.

This blog will overview a complete procedure to run the PowerShell and the relevant script in Command Prompt.

How to Run PowerShell in CMD?

PowerShell can easily be launched in CMD by following the given steps.

Step 1: Launch CMD

First, navigate to the Start menu and launch “Command Prompt”:

Step 2: Run PowerShell in CMD

Execute the given “powershell” cmdlet to run the PowerShell in CMD:

> powershell

The “PowerShell” is executed/run successfully in CMD.

How to Run the PowerShell Script in CMD?

After running the “PowerShell” in CMD, let’s test the working of the PowerShell. For that reason, follow the given steps.

Step 1: Enable Remote Signed Execution

In order to run the “PowerShell” script in CMD, the “RemoteSigned” execution policy needs to be enabled. For that reason, execute the given command:

> Set-ExecutionPolicy RemoteSigned

The RemoteSigned policy is used to run the scripts created locally. However, the scripts downloaded from the internet can also be executed, but they need to be digitally signed by the publisher:

Step 2: Execute the PowerShell Script

Now, let’s execute the PowerShell script. To do so, write the “Invocation Operator &” at the start, and specify the script path within inverted commas:

> & "C:\Users\Muhammad Farhan\Desktop\Test.ps1"

As you can see from the output, the PowerShell script has been executed successfully in CMD.

Conclusion

To run the PowerShell in CMD, first, launch “Command Prompt” and execute the “PowerShell” command. In order to check the working of the PowerShell in CMD, first, enable the execution of the commands/scripts. For that reason, execute the “Set-ExecutionPolicy RemoteSigned” cmdlet and run the relevant script. This tutorial has demonstrated a complete procedure to run PowerShell in CMD.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.