Loading VMM and vSphere cmdlets into the same PowerShell Console

Hello everyone,

This is Hector Linares, Program Manager for storage automation and with help from Erwien Saputra, UI developer on the Virtual Machine Manager team. We want to show you how to load VMM and vSphere cmdlets in the same PowerShell console.

Administrators that need to manage both Hyper-V and ESX in their environment, can use VMM to manage both. However, sometimes it is necessary to configure specific setting only available in vSphere. By loading VMM and vSphere cmdlets into the same console gives you access to both VMM and vSphere from a single console.

To set this up:

1. Download and install VMware vSphere PowerCLI on the same machine that has VMM Administration Console: http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

2. Create a folder ToolBox in %SYSTEMDRIVE% (this post assumes %SYSTEMDRIVE% but this can be in any location)

3. Create sub-folder VMMCLI in ToolBox folder

4. Create PowerShell script file named LoadScript.ps1 and save it to %SYSTEMDRIVE%\ToolBox\VMMCLI. The file should contain the following script:

if ((Get-ExecutionPolicy) -eq 'Restricted') {

Set-ExecutionPolicy RemoteSigned -Scope Process -Force}

ipmo 'C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1'

Add-PSSnapIn -NameVMWare.VimAutomation.Core

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


$productName = "VMM and vSphere PowerShell Console"

$host.ui.RawUI.WindowTitle = "[$productName]"

5. Create a shortcut to PowerShell console and save it to %SYSTEMDRIVE%\ToolBox\VMMCLI. The shortcut should have the following setting:

Target: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe  -c "Set-Location -Path %SYSTEMDRIVE%\toolbox\VMMCLI; .\loadscript.ps1"


6. You can now double click on the shortcut and get a PowerShell console with
VMM and vSphere cmdlets

Keep in mind:

1. This script assumes you have the latest VMM build installed. If you are using BETA, you will need to change VMM path:

- VMM 2012 BETA:          “C:\Program Files\Microsoft System Center Virtual Machine Manager 2012”

- VMM 2012 RC/RTM:     “C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager”

2. Even though all VMM cmdlets have been renamed, some vSphere cmdlets overlap with VMM alias (e.g. Get-VM). The cmdlets loaded last take precedence so if you execute Get-VM for example, the vSphere implementation of Get-VM will be invoked. VMM’s new name for get-VM is Get-SCVirtualMachine.


Happy Scripting!

Comments (0)

Skip to main content