How to Run a PowerShell Script ?

There are many ways in which you can run your PowerShell Script. In this post , we will how to run the powershell script via command prompt and via Windows PowerShell.

How to Run a PowerShell Script ?

Assume that the path of the script is “C:\DP.ps1”. Ton run the script from the command prompt , use the below command.

powershell -noexit "& ""C:\DP.ps1"" (enter)

You can also launch Windows PowerShell and once the PS command prompt appears , navigate to the folder where the script file exists.

PS> CD c:

Now , execute the script by specifying the name of the script and press the enter key.

PS> .\DP.ps1

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Are you looking at importing DscResource with Relative Paths when working in PowerShell? If so, let’s have a look at...
In this post, let’s learn about the Powershell error “The file <Filename> is not digitally signed. You cannot run this...
If you are new to PowerShell and wondering how to add comments with-in your Powershell code , here’s how you...