Run As Administrator (Elevated)

Dot Sourcing

When you dot sourcea script, all variables and functions defined in the script will persist even when the script ends.

Run a script by dot-sourcing it:

PS C:\> . "C:\Belfry\My first Script.ps1"

Dot-sourcing a script in the current directory:

PS C:\> . .\Myscript.ps1"

Run a CMD batch file

Run a batch script from PowerShell: PS C:\> ./demo.cmd

If the batch
script contains any internal commands then it must be run by calling the CMD.exe shell and passing the batch file: PS C:\> C:\windows\system32\cmd /c c:\batch\demo.cmd
Note, this works for .cmd but not .bat files.

Run a VBScript file

Run a vb script from PowerShell: PS C:\> cscript c:\batch\demo.vbs

The System Path

If you run a script (or even just enter a command) without specifying the fully qualified path name, PowerShell will search for it as follows: