Invokes a script block in a separate powershell.exe process.
Invoke-PowerShell [-Command] <ScriptBlock> [[-Args] <Object[]>] [-x86] [[-Runtime] <String>] [<CommonParameters>]
The invoked PowerShell process can run under the .NET 4.0 CLR (using v4.0
as the value to the Runtime parameter) and under 32-bit PowerShell (using the x86
switch).
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Command | ScriptBlock | The command to run. | true | false | |
Args | Object[] | Any arguments to pass to the command. | false | false | |
x86 | SwitchParameter | Run the x86 (32-bit) version of PowerShell. | false | false | |
Runtime | String | The CLR to use. Must be one of v2.0 or v4.0. Default is v2.0. | false | false |
Invoke-PowerShell -Command { $PSVersionTable }
Runs a separate PowerShell process, returning the $PSVersionTable from that process.
Invoke-PowerShell -Command { $PSVersionTable } -x86
Runs a 32-bit PowerShell process, return the $PSVersionTable from that process.
Invoke-PowerShell -Command { $PSVersionTable } -Runtime v4.0
Runs a separate PowerShell process under the v4.0 .NET CLR, returning the $PSVersionTable from that process. Should return a CLRVersion of 4.0
.