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