Using the Invoke-Expression Cmdlet
The Invoke-Expression cmdlet provides one way to run a script from within Windows PowerShell. For example, this command runs the script C:\Scripts\Test.ps1:
Invoke-Expression c:\scripts\test.ps1
Alternatively you can use the ampersand to indicate that you want to run a script:
& c:\scripts\test.ps1
Or, even easier, just type in the path to the script:
c:\scripts\test.ps1
In all cases any paths that include blank spaces must have the entire path enclosed in double quote marks:
Invoke-Expression "c:\my scripts\test script.ps1"
Invoke-Expression Aliases |
---|
|