Click to Rate and Give Feedback
TechNet
TechNet Library
Scripting
Script Center
Windows PowerShell
Cmdlets
 Using the Invoke-Expression Cmdlet
What Can I Do With Windows PowerShell?
Using the Invoke-Expression Cmdlet

Running a Windows PowerShell Script

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
  • iex

Related Links

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker