Get-PowerCLIContext
This cmdlet retrieves the VCF PowerCLI execution context which you can use to simplify the use of PowerCLI in PowerShell runspaces. The PowerCLI execution context includes the imported VCF PowerCLI modules and their established connections.When you use VCF PowerCLI in PowerShell runspaces you have two options.The first option is to import your connections manually, for example, a vCenter Server system connection, and pass them to the corresponding cmdlets using the Server parameter.The second option is to use the Get-PowerCLIContext () cmdlet to retrieve VCF PowerCLI execution context and then use the [Use-PowerCLIContext]()cmdlet prior to using VCF PowerCLI cmdlets in the new PowerShell runspace.
Syntax
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
optional | ProgressAction | ActionPreference | named |
|
Output
VMware.VimAutomation.Common.Types.V1.ExecutionContext.PowerCliContextExamples
Example 1
$context = Get-PowerCLIContext
Retrieves the current VCF PowerCLI context into the $context variable.
Example 2
$context = Get-PowerCLIContext 1..5 | ForEach-Object -Parallel { Use-PowerCLIContext -PowerCLIContext $using:context New-VM -Name "MyVM_$_" -VMHost (Get-VMHost 'MyVMHost') -MemoryMB 128 -DiskMB 256 }
Retrieves the current PowerCLI execution context and initializes each new PowerShell runspace created by ForEach-Object -Parallel.
Related Commands
PowerCLIConfiguration
This cmdlet retrieves the VCF PowerCLI proxy configuration and default servers policy.
This cmdlet modifies the VCF PowerCLI configuration.
PowerCLIContext
This cmdlet retrieves the VCF PowerCLI execution context which you can use to simplify the use of PowerCLI in PowerShell runspaces.
This cmdlet initializes a PowerShell runspace with a PowerCLI execution context retrieved from another PowerShell runspace.
PowerCLIVersion
This cmdlet retrieves the versions of the installed PowerCLI snapins.