How to properly initialize PowerCLI 6.x in PowerShell ISE

With the release of vSphere 6.0 VMware has started to transform their distribution model of PowerCLI cmdlets from PSSnapins into modules. This is a good thing because modules are the preferred method of adding cmdlets to PowerShell. Unfortunately the changed behavior breaks plenty instructions on how to load VMware PowerCLI in ISE, including my own. The old method works for core cmdlets, but functions related to Distributed Switches or Storage Policies for example are missing.

If you have the latest version of PowerCLI installed but cmdlets are missing in PowerShell ISE, maybe you are using the old method to load cmdlets.

Get-VDSwitch : The term ‘Get-VDSwitch’ is not recognized as the name of a cmdlet, function, script file, or operable program.

Do no longer use this command in Microsoft.PowerShellISE_profile.ps1
Add-PsSnapin VMware.VimAutomation.Core -ea “SilentlyContinue”

It will only load the Snapin:

…not the Modules…

…which results in the following cmdlets to be missing:



Connect-PIServer, Disconnect-PIServer, Get-PIComputeInstance, Get-PIDatacenter

Export-SpbmStoragePolicy, Get-NfsUser, Get-SpbmCapability, Get-SpbmCompatibleStorage, Get-SpbmEntityConfiguration, Get-SpbmStoragePolicy, Get-VAIOFilter, Get-VasaProvider, Get-VasaStorageArray, Get-VsanDisk, Get-VsanDiskGroup, Import-SpbmStoragePolicy, New-NfsUser, New-SpbmRule, New-SpbmRuleSet, New-SpbmStoragePolicy, New-VAIOFilter, New-VasaProvider, New-VsanDisk, New-VsanDiskGroup, Remove-NfsUser, Remove-SpbmStoragePolicy, Remove-VAIOFilter, Remove-VasaProvider, Remove-VsanDisk, Remove-VsanDiskGroup, Set-NfsUser, Set-SpbmEntityConfiguration, Set-SpbmStoragePolicy, Set-VAIOFilter

Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch, Get-VDBlockedPolicy, Get-VDPort, Get-VDPortgroup, Get-VDPortgroupOverridePolicy, Get-VDSecurityPolicy, Get-VDSwitch, Get-VDSwitchPrivateVlan, Get-VDTrafficShapingPolicy, Get-VDUplinkLacpPolicy, Get-VDUplinkTeamingPolicy, New-VDPortgroup, New-VDSwitch, New-VDSwitchPrivateVlan, Remove-VDPortGroup, Remove-VDSwitch, Remove-VDSwitchPhysicalNetworkAdapter, Remove-VDSwitchPrivateVlan, Remove-VDSwitchVMHost, Set-VDBlockedPolicy, Set-VDPort, Set-VDPortgroup, Set-VDPortgroupOverridePolicy, Set-VDSecurityPolicy, Set-VDSwitch, Set-VDTrafficShapingPolicy, Set-VDUplinkLacpPolicy, Set-VDUplinkTeamingPolicy, Set-VDVlanConfiguration

Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition, Get-OMAlertSubType, Get-OMAlertType, Get-OMRecommendation, Get-OMResource, Get-OMStat, Get-OMStatKey, Get-OMUser, Set-OMAlert

To load PowerCLI properly, use the the Initialize-PowerCLIEnvironment.ps1 script located at C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts (delivered with the installer).

  1. Open PowerShell ISE
  2. Create and open your profile with:
    New-Item -Path $Profile -ItemType file -Force
    notepad $profile
  3. Notepad will open with an empty file. Enter the following command:
    & 'C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1'
  4. Restart PowerShell ISE


Please note that this might be not best practise for everyone. If you are using PowerCLI ISE with small prepared snippets for your daily administration like me, its fine. If you want to write and distribute comprehensive scripts its better to make the script to load the correct module.

  1. For the same reason I wrote my Enable-PowerCLI function.

  2. Instead ‘&’ you can use ‘dot sourcing”

    . ‘C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1’

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>