Powershell: Invoke-Expression

Powershell Header

Using the Invoke-Expression Cmdlet:

The Invoke-Expression cmdlet provides one way to run a script from within Windows PowerShell.

Invoke-Expression c:\scripts\test.ps1

or

& c:\scripts\test.ps1

And you also can run a function in your Powershell Script by a variable. This is something really important when you work with dynamic scripts:

Invoke-Expression -command ($Function_Name)

you even can send dynamic parameters to this function:

Invoke-Expression -command ($Function_Name + ' $Function_Parameters')