Hi All,
What is the easiest way to run powercli (6.5) on powershell ISE(5.0)
any help is much appreciated.
When you have PowerCLI 6.5.1, or later, installed from the PowerShell Gallery, in principle you will not have to do anything.
The PowerShell auto-load feature will load the required module automatically when you type the first cmdlet from that module.
As a test, make sure no modules are imported.
Start the ISE, then type for example 'Connect-', the Intellisense feature will show you all the possible cmdlets.
That is achieved through the auto-loading feature.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
Thanks for your response but it was not installed from powershell gallery.
however there is some discussion about editing following two profile files.
# Load Windows PowerShell cmdlets for managing vSphere
Add-PsSnapin VMware.VimAutomation.Core -ea "SilentlyContinue"
but above does not work .could you comment on above process if that can be made working in case something is missing .
The PowerCLI versions before 6.5R1 were a combination of PSSnapin and Modules, you will have to load all of those, at least the ones you are planning to use cmdlets from.
I posted one way of doing that in Universal PowerCLI Loader
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello, You can try this instead - Import-module vmware.vimautomation.core This works fine for me.
--------
Branav.
That only loads 1 module, and ignores the PSSnapin.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Iam checking this.
Hi Branav,
thnaks for replying .i imported the module and checking to import other modules also .
Hello JVM,
Just a guess, but haven't tried this before. Not in front of my pc now to give a try though.
Right click powercli shortcut icon > properties > General tab > location - it should be pointing to some .psm1 file. We can try running that .psm1 file from powershell.
Afaik, the PowerCLI shortcut, which is not used anymore, was pointing to an init script (.ps1), not a module (.psm1)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
That is correct, It was .ps1 file. My bad memory
But, I can still see shortcut for Powercli 6.5. And the shortcut is pointing to "C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1".
I tried running Initialize-PowerCLIEnvironment.ps1 from powershell, It works like charm.
Hello JVM,
Eaiset way to accomplish your goal is execute the below .ps1 file in powershell.
"C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1".
Or alternative way is to save the below content in .ps1 file and execute it from powershell window.
Import-module VMware.VimAutomation.Core
Import-module VMware.VimAutomation.Vds
Import-module VMware.VimAutomation.Cloud
Import-module VMware.VimAutomation.PCloud
Import-module VMware.VimAutomation.Cis.Core
Import-module VMware.VimAutomation.Storage
Import-module VMware.VimAutomation.HorizonView
Import-module VMware.VimAutomation.HA
Import-module VMware.VimAutomation.vROps
Import-module VMware.VumAutomation
Import-module VMware.DeployAutomation
Import-module VMware.ImageBuilder
Import-module VMware.VimAutomation.License
I have tried both methods, And it works.
Using Initialize-PowerCLIEnvironment.ps1 is a bad habit, since starting with 6.5.1 that .ps1 doesn't exist anymore.
Only running Import-Module doesn't take into account that the requestor's version also contains PSSnapin.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
jvm2016
After installing powercli 6.5, modified the file Microsoft.PowerShellISE_profile.ps1 to include the below contents :
# Load Windows PowerShell with cmdlets for managing vSphere
Import-Module VMware.PowerCLI
This auto loaded all the powercli cmdlets into powershell ISE.
Location of file : C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
So...
maybe i am wrong. But i think i had the same problems days ago.
You need to put the modules into the module path and the will be load automatic.
Show wich module pathes you have
$env:PSModulePath
Add new Location to the module path:
$env:PSModulePath = $env:PSModulePath + ";c:\ModulePath"
To fix this you can put this line in your Profile file.
Than you can use all the modules with the Auto load feature.
Sry if i missed something important.