rob.rfg
rob.rfg

Reputation: 1

Cmdlet Contention between PowerShell SnapIns

I ran into an issue while using both the Vmware PowerCLI and System Center Virtual Machine Manager snap-ins for PowerShell. They both contain similarly named cmdlets, like 'Get-VM' and 'Get-VMHost'. It appears that the last snap-in to load wins, so I added logic in my script to load & un-load the snap-in when I needed to get either VMware data or Hyper-V data. I'd like to know if there is any way to prevent this contention, or otherwise create some unique handle to one cmdlet, while still allowing the other to load & operate as intended?

Upvotes: 0

Views: 530

Answers (2)

Dave
Dave

Reputation: 21

And for anyone searching for the actual namespace/prefix for VMware's vSphere PowerCLI snapin cmdlets, it's:

VMWare.VimAutomation.Core

Hence the real prefix for the example above is:

VMware.VimAutomation.Core\Get-VM

Upvotes: 2

Keith Hill
Keith Hill

Reputation: 201652

The best approach when using snapins is to fully qualify the cmdlet name with the snapin name. For instance, if the snapin name for PowerCLI is PowerCLI then use:

PowerCLI\Get-VM

For the SCVMM snapin use it's name as a prefix. To see the snapin names, execute:

Get-PSSnapin -Registered

Upvotes: 2

Related Questions