VMware Cloud Community
nelmedia
Contributor
Contributor

Clash of the PoSH / PowerCLI cmdlets

So, I learned today the hard way that by adding the vSphere Powercli snapins to my PoSH 3.0 session on a server 2012 with the Hyper-V role enabled, that there are several cmdlet names that clash by name, causing all kinds of havok in my long running, tried & true scripts. Both PowerCLI and PoSH native have Get-VM, Set-VM, Get-Cluster, and many others. The only way to execte them to the right Group is to prefix them with the Module name (Hyper-V\Get-VM). Now this sounds easy, but going through all my existing scripts to fix this is a bit much, and remmebering to do it on the command line will also prove difficult. And it really is a duct tape fix in my opinion.

Since the Hyper-V cmdlets are now native to the PoSH Core, how are we to have the two live in harmony and peace?

I understand that you can add a -Prefix parameter to the end of the Import-Module cmdlet to help (but not fix) this situation, but low and behold, the PowerCLI is still not been made into a proper PoSH module, but still and old PSSnapin.

Any ideas?

Thanks to all.

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

I think you described the problem, more and more of us are facing nowadays, very concise and correctly.

Alan will not like me for this :smileymischief:, but PowerCLI as a module is the only way out I can see.

In any case it beats changing all your

Get-VM

lines into

VMware.VimAutomation.Core\Get-VM


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

Reply
0 Kudos