VMware Cloud Community
MSpriya
Contributor
Contributor
Jump to solution

Get-VirtualPortGroup Value cannot be null. Parameter name: collection

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 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Yes, currently PowerCLI is not thread-safe


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

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Yes, currently PowerCLI is not thread-safe


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

0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

Oh ok, although some commands seem to work fine when run in parallel. 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

MSpriya
Contributor
Contributor
Jump to solution

Thank you @LucD , that was very helpful. 

0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

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? 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos