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.
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
2 people found this helpful
Hello, You can try this instead - Import-module vmware.vimautomation.core This works fine for me.
That only loads 1 module, and ignores the PSSnapin.
Thanks Iam checking this.
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)
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.
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.
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.
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
This auto loaded all the powercli cmdlets into powershell ISE.
Location of file : C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
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
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.