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?
Asked
Active
Viewed 524 times
2 Answers
2
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

Keith Hill
- 194,368
- 42
- 353
- 369
2
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

Dave
- 21
- 1