Hi there
So i use ISE for both Powershell and PowerCLi scripting, but I have recently noticed an issue with a script I use.
The script I use deploys Linked Clones to our ESXi environment, and until recently has been running fine in the ISE.
I now get an error saying the Hyper-V role is not installed on the destination host.
I assume I am getting this because the Script i run uses the Get-VM command, and this command is also a Hyper-V command
I am not sure how to resolve this and differentiate the 2 commands
Thanks for your help
Ok, since PowerCLI 6.5R1 there are no more PSSnapin, only modules.
The Hyper-V module is installed on your system when you for example install the Remote Administration Tools on your desktop.
Once the Hyper-V module is installed, the cmdlets in that module are automatically "known" to the PowerShell engine, through something that is called auto-loading and the folders defined in the $env:PSModulePath variable.
The Hyper-V module contains a Get-VM cmdlet.
When you now load the PowerCLI modules, you get the PowerCLI version of the Get-VM cmdlets as well.
You can check by running
Get-Command -Name Get-VM
The easiest solution is of course not to load cmdlets with the same name from multiple modules.
If you don't use Hyper-V, you could remove/rename the Hyper-V module folder.
Otherwise you can the Prefix parameter on the Import-Module cmdlet.
Import-Module -Name Hyper-V -Prefix 'HV'
Get-HVVM
This way the cmdlets in the Hyper-V module get the Prefix you specified on the Noun part of the cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
This article has some tips on handling this situation.
Thanks yezdi
I'll have a read of the article
I'm wondering why its just started happening..I dont think anything has changed recently on my system.....
by any chance did you enable the hyperv role on your machine?
Is Powershell ISE loading PowerCLI module correctly ? This should happen when Powershell doesn't recognize PowerCLI commands. Try executing below command before script.
Add-PsSnapin VMware.VimAutomation.Core -ea "SilentlyContinue"
No, I havent done that yet
I am running a server 2012 VM inside ESXi 5.5
Which PowerCLI version are you running?
Do a Get-PowerCLIVersion
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am running - VMware PowerCLI 6.5 Release 1 build 4624819
Ok, since PowerCLI 6.5R1 there are no more PSSnapin, only modules.
The Hyper-V module is installed on your system when you for example install the Remote Administration Tools on your desktop.
Once the Hyper-V module is installed, the cmdlets in that module are automatically "known" to the PowerShell engine, through something that is called auto-loading and the folders defined in the $env:PSModulePath variable.
The Hyper-V module contains a Get-VM cmdlet.
When you now load the PowerCLI modules, you get the PowerCLI version of the Get-VM cmdlets as well.
You can check by running
Get-Command -Name Get-VM
The easiest solution is of course not to load cmdlets with the same name from multiple modules.
If you don't use Hyper-V, you could remove/rename the Hyper-V module folder.
Otherwise you can the Prefix parameter on the Import-Module cmdlet.
Import-Module -Name Hyper-V -Prefix 'HV'
Get-HVVM
This way the cmdlets in the Hyper-V module get the Prefix you specified on the Noun part of the cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD, I renamed the folder and the script is working fine