VMware Cloud Community
Pavlik972
Contributor
Contributor

Start-job problems when re-using the same vCenter session

I have a PowerCLI script I use to register VM on a vCenter ( DR infrastructure ).

I have to change the Portgroup because it has a different name from the production site.

With the new version of the PowerCLI the script fails to update the network adapter configuration:

11/17/2020 10:11:02 AM New-VM No Lookup service information is available for this vCenter server.
+ CategoryInfo : InvalidOperation: (:) [New-VM], VimException
+ FullyQualifiedErrorId :
ViCore_ConnectivityServiceImpl_GetLookupServiceClient_NoClient,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
+ PSComputerName : localhost
11/17/2020 10:11:02 AM New-VM No Lookup service information is available for this vCenter server.
+ CategoryInfo : InvalidOperation: (:) [New-VM], VimException
+ FullyQualifiedErrorId : ViCore_ConnectivityServiceImpl_GetLookupServiceClient_NoClient,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
+ PSComputerName : localhost

I found some threads, and I found a workaround: In the start-job I pass the credential and open a new session to the vCenter and the VM reconfig works fine, but I would like to know if the problem will be corrected ( or has already been corrected in a newer versione of the PowerCLI modules : VMware PowerCLI 12.1.0 build 17009493 ) or if this is a VMware choise for some unkwnown ( for me ) reasons.

 

Thanks in advance.

 

Pavlik

0 Kudos
12 Replies
LucD
Leadership
Leadership

That is indeed a known issue when you use Start-Job or Start-Process and use a SessionId on the Connect-VIServer cmdlet.

Unfortunately, you didn't specify which vSphere version you are running this against.
In any case, I would suggest opening an SR for the issue.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Pavlik972
Contributor
Contributor

Thanks Luc,

I'll evaluate the possibility to open an SR 👍

The vCenter Server version I'm using is the 6.7

0 Kudos
LucD
Leadership
Leadership

Just to make sure this is indeed the known issue I referred to, do you use the SessionId on the Connect-VIServer in the Start-Job code?
In the cases I have seen, it works when the Connect-VIServer is done with Credentials.
You could consider using a VICredentialStoreItem as a bypass.

Btw, when you open an SR, GSS might claim (incorrectly) that you need a Developer Support contract for PowerCLI issues.
That is not correct, in that case, point them to PowerCLI Support Breakdown. 





Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Pavlik972
Contributor
Contributor

Yes, I use this global variable:

$global:DefaultVIServer.SessionSecret

I pass it in the argument list for using it during the connection to the vCenter in the backgroun job :

Connect-VIServer $vc -session $ses

This way a receive the error.

It starts working, after I changed the command and used the -credential ( passing the variable that stores them instead of the session id ).

 

Thanks for the "SR suggestion".

 

Have a Nice Day

 

0 Kudos
Pavlik972
Contributor
Contributor

I made some more experiments, and at the end this is the situation:

the "No lookup Service" error begins already with the VM registration with the cmdlet "New-VM".

In a normal situation, the command waits the registration completion before continuing the script with the network card reconfiguration, but when the error is thrown, the command doesn't wait for the registration completion e try to reconfig the network card of a VM yet not present.

But the registration task is running and it completes after a while.

If I add a while (!get-vm) do { sleep 1} (simplified) then the reconfig is successfully completed ( even if I receive the "no Lookup Service" error on the console ).

So it seems that this error doesn't means the command is not processed and completed.

The error is shown also with the -erroraction silently continue 🤔

0 Kudos
v3mattia
Contributor
Contributor

Hi LucD
where is the best place to get support from VMware on PowerCLI issue ?

Tags (1)
0 Kudos
LucD
Leadership
Leadership

The regular contact point (GSS).
If they claim you need a Developer (or SDK) Support contract, point them to PowerCLI Support Breakdown


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CSOCloud
Contributor
Contributor

Hello @LucD , do you know if this issue was ever solved in later releases? I'm having this issue as well and almost 3 years had passed. I'm trying to run scripts reusing an already open connection to the vcenter. I'm also waiting on a response from GSS

0 Kudos
LucD
Leadership
Leadership

With vSphere 7.* and PowerCLI 13.* I don't seem to encounter the issue anymore.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CSOCloud
Contributor
Contributor

Hello,

I'm currently testing using vSphere 7.0.3  and VMware.PowerCLI 13.1.0 build 21624340, but the issue seems to still be present.

Simply using the sessionID while connection to another pwsh session and doing "Get-TagAssignment" returns the same error:

Get-TagAssignment: 7/11/2023 2:03:34 PM Get-TagAssignment No Lookup service information is available for this vCenter server.

 

0 Kudos
LucD
Leadership
Leadership

I was referring to a Start-Job task, not a completely different PS session.
In that case, you could try explicitly importing all the PowerCLI modules before

Import-Module -Name VMware.PowerCLI

 

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CSOCloud
Contributor
Contributor

Hello,

We were also using start-job but I've noticed that it was also happening if we used a separate PS session.

Importing PowerCLI did not solve the issue. I've sent the "Get-ErrorReport" to GSS and they're looking into it

0 Kudos