Initializing PowerCLI Modules in PowerShell ISE

starting from vSphere 6.0 release VMware has started using modules instead of PSSnapins in their distribution model of PowerCLI

so today we are going to show how to load PowerCli Module in PowerShell ISE

The PowerShell Integrated Scripting Environment (ISE) easy to use with VMware PowerCLI. When  writing  a script or a one-liner, one of the first things you should do is to load the necessary Modules .  you can automate this process to load necessary Modules automatically when starting PowerShell ISE with the help of the powershell ISE profile . it is a PowerShell script file . Because of this, you can write everything (cmdlets, scripts, functions etc.) in this script file, and it will be executed when you start the PowerShell ISE.

where can you find the Windows PowerShell profile files? The path to the PowerShell profile can found with variable $profile.

PS C:\>$profile

Usually the files doesn’t exist, except you created them. Check if the files exist. If not, this command will create an empty profile file

PS C:\Users\vSaiyan> Test-Path $profile

PS C:\Users\vSaiyan> New-Item -path $profile -type file -force

PS C:\Users\vSaiyan> Test-Path $profile

10-24-2017 7-40-25 AM

after creating $profile  open it with notepad and put the following command this will load the PowerCli Modules when open PowerShell ISE

cd "C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts"
cd c:\

Save the File and restart powerShell ISE

10-24-2017 7-50-25 AM10-24-2017 7-50-39 AM

Now PowerCli loaded as shown and you can start using PowerCLI cmdlet

you can also write script to load correct PowerCLI Modules you are using .