There are several ways in which you can run or execute PowerShell scripts from within the PowerShell command window if you do not have a PowerShell editor such as PowerShellIDE.
To run the PowerShell scripts that you have created open the PowerShell command window and enter the scripts file path and name as in the example below:
C:\MyFile.Ps1
You can also preface your script with the ampersand as shown below:
& C:\MyFile.Ps1
Note: If you have spaces in your command line you will have to quote them as shown in the samples below:
"C:\PowerShell Scripts\ MyFile.Ps1"
"C:\Scripts\ My File.Ps1"
You can also invoke PowerShell and run your script from a batch file as shown here:
PowerShell C:\Test.ps1
Pause
The other programming language of choice for me in particular is VB script. You can start PowerShell from VB script and run your script using WshShell.Run as in the example below:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "Powershell C:\Test.Ps1", , True
No Comments