Hello,
I was trying to reuse a VCENTER server connection in an start-JOB scriptblock, others commands are working fine like get-vm etc... but GET-Vdswitch or Get-VDportgroups reports the following error when are launched on a reconnected session
get-vdswitch
31-Aug-19 5:34:43 PM Get-VDSwitch No Lookup service information is available for this vCenter server.
+ CategoryInfo : InvalidOperation: (:) [Get-VDSwitch], VimException
+ FullyQualifiedErrorId : ViCore_ConnectivityServiceImpl_GetLookupServiceClient_NoClient,VMware.VimAutomation.Vds.Commands.GetVDSwitch
+ PSComputerName : localhost
31-Aug-19 5:34:43 PM Get-VDSwitch VDSwitch with name 'MYSWITCH' was not found using the specified filter(s).
+ CategoryInfo : ObjectNotFound: (:) [Get-VDSwitch], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.Vds.Commands.GetVDSwitch
+ PSComputerName : localhost
get-vdportgroup
get-vdportgroup : 31-Aug-19 5:22:18 PM Get-VDPortgroup No Lookup service information is available for this vCenter server.
At line:1 char:1
+ get-vdportgroup
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-VDPortgroup], VimException
+ FullyQualifiedErrorId : ViCore_ConnectivityServiceImpl_GetLookupServiceClient_NoClient,VMware.VimAutomation.Vds.Commands.Cmdlets.GetVDPortgroup
I'm using latest powercli version downloaded from powershellgallery
My Test Job is the following,
$block={
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
$VCenter,
$vmSessID
)
$vcenter
$vmSessID
$null=Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -DisplayDeprecationWarnings $false -ProxyPolicy NoProxy -Confirm:$false
Connect-Viserver $Vcenter -Session $vmSessID
get-vm VMTEST # this command works fine
get-Vdswitch -name 'MYSWITCH' # this command Fails
get-vdsportgroup # this also fails
}
JOB is started in the following way
$visession=connect-vicenter 'MyVicenter'
start-job -scriptBlock $block -argumentlist $Visession.name $Visession.SessionSecret
The only workaround I've found until now, was start this Job connection with a completely new session to the same VCenter.
But, there is a way to reuse / reconnect to an existing session for these commands?
Regards