How to start a PowerShell script from a batch file

Home > Search > How-to
  by

Let's say you have a batch file named MyBatch.bat. The batch file can execute a PowerShell script by using Powershell.exe and then the path to the PowerShell file. In this example, MyBatch.bat will execute the PowerShell script named Example.ps1 located at C:.

Powershell.exe -File  C:/Example.ps1

 

In this example, MyBatch.bat will execute the PowerShell script named Example.ps1 located on the network drive \\server1\share.

Powershell.exe -File  \\server1\share\example.ps1

 


Execution Policy

Some PowerShell scripts will require a certain Execution Policy. The -executionpolicy option can be used to run the script using a certain Execution Policy. In this example, the Remote Signed Execution Policy is used.

Powershell.exe -executionpolicy remotesigned -File  \\server1\share\example.ps1

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments