Hi,
I am getting this exception when I try to run Get-VirtualPortGroup PowerCLI command in parallel in multiple threads from a .net application.
Get-VirtualPortGroup Value cannot be null.
Parameter name: collection
The exception is seen consistently for few of the parallel command executions. For example, if 4 Get-VirtualPortGroup commands are run in parallel, exceptions are seen for 2-3 executions.
However, when the command is run sequentially, the exception is not thrown.
Exact command used is:
Get-VirtualPortGroup -Name <PortGroupName> -DataCenter <Datacenter> -Server <session>
Has anyone faced this issue before?
PowerCLI version - 11.4.0
PS C:\Windows\system32> (Get-Module -Name VMware.PowerCLI -ListAvailable).Version
Major Minor Build Revision
----- ----- ----- --------
11 4 0 14413515
vCenter version: 6.5
Any thoughts?
Thank you
Yes, currently PowerCLI is not thread-safe
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, currently PowerCLI is not thread-safe
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh ok, although some commands seem to work fine when run in parallel.
Yes, that is indeed the case.
The only parallelism that is usable is via Start-Job or runspaces with a single thread.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you @LucD , that was very helpful.
Even though Get-VirtualPortGroup command execution is synchronized with mutex lock, I am getting the same exception at random. I am not sure if this is actually related to parallel execution of the PowerCLI command.
@LucD , any idea what could be the issue here?
If the issue doesn't occur in a single thread execution, then the problem most probably is related to the parallelism.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference