SCVMM PowerShell module trick: Skip the management tool install

Learn how to get the cmdlets you need to manage SCVMM from anywhere in the world by using Remoting to import a PowerShell module.

With PowerShell Remoting, you can now use VMM cmdlets to remotely manage SCVMM from any computer, without installing the SCVMM management tools. This can be a huge time saver for admins or consultants who cannot or don't want to install management tools on a personal or remote computer.

If you haven’t used PowerShell to manage Microsoft System Center Virtual Machine Manager (SCVMM), now is the time to consider adding it to your repertoire -- if for no other reason than to assist in automating common tasks. SCVMM servers include a PowerShell module that contains 529 cmdlets to manage all aspects of SCVMM -- similar to VMware’s PowerCLI.

Many IT pros, excited at the prospect of using PowerShell to manage SCVMM, immediately jump into a remote desktop protocol (RDP) session to the server, open the SCVMM management console and begin to work. RDP is fine, but it's not helpful if you are running Windows Server Core and impacts the performance of the server if you have the graphical desktop. The better method is to install the SCVMM management tools on your local client, which minimizes the impact on server performance.

As a consultant, I never know what computer I'm going to be using at a client site, so taking the time to install the management tools – even if permitted – takes too long. Even if I'm sitting in my home office, I don’t want all these management tools, some which conflict with each other, installed on my PC. I'm going to show you a better solution, one you can use on any computer and that doesn't require any additional software. The same solutions I describe here will work for other products you might manage, such as Microsoft Exchange, Hyper-V and VMware vSphere.

Before you begin, there are a few PowerShell requirements that you need to fulfill.

What you need to get started

The magic that makes remote management of SCVMM easy is a technology built into PowerShell called Remoting. This is truly the magic sauce of PowerShell administration and allows you to manage multiple servers, software or any object from your desktop. The trick is that PowerShell Remoting and a script execution policy must be enabled on the target servers.

PowerShell Remoting is enabled by default on Windows Server 2012, but you will need to enable PowerShell Remoting in Windows Server 2008 and 2008 R2.

Once you have enabled Remoting and script execution policy, you're ready to manage SCVMM like never before. Let me show you two very useful ways to do this.

One-to-one Remoting

One-to-one Remoting is often compared to Secure Shell or Telnet, and while it's very different under the hood, the concept is similar. I like to think of it as the best way to remotely control a server without the horrible performance impact of loading graphical programs on a server.

When you connect to a remote server using one-to-one Remoting, your prompt will change to include the remote server's computer name. When you run commands, the commands run on the remote server. In the example below, the Enter-PsSession cmdlet uses PowerShell Remoting to connect to the remote SCVMM server. To get the 529 cmdlets loaded to manage SCVMM, use the Import-Module cmdlet to import the "VirtualMachineManager" PowerShell module.

PS C:\> Enter-PSSession -ComputerName SCVMM1

[SCVMM1]: PS C:\> Import-Module –Name VirtualMachineManager

[SCVMM1]: PS C:\> Get-SCVMMServer –ComputerName SCVMM1

One-to-one Remoting works very well if you need to manage or troubleshoot a server, but I often find that I also need to use the Hyper-V cmdlets from one of my hosts, along with the Active Directory cmdlets from a domain controller. Because I need multiple modules from a variety of products and servers, one-to-one Remoting is not the solution. Instead, I use implicit Remoting.

Implicit Remoting

This is my favorite method of working with SCVMM and other products, and it's the one I use almost every time, unless I simply need to isolate an issue on a specific server with a one-to-one connection.

The magic is that the PowerShell module on a remote server -- and the cmdlets inside it -- can be imported to the console. The cmdlets will stay active as along as the console remains open. This entirely removes the need to install management tools directly on your client.

Using the New-PsSession cmdlet, you create a session to the remote servers that contain the modules of cmdlets you want. For SCVMM, the example below connects to the SCVMM server, imports the PowerShell module on the server and then imports the cmdlets to your desktop.

PS C:\> $session=New-PSSession -ComputerName SCVMM1

PS C:\> Invoke-Command –Session $Session {Import-Module –Name VirtualMachineManager}

PS C:\> Import-PSSession -Session $session -Module VirtualMachineManager

On your local desktop, you can run the SCVMM cmdlets just as if you had installed the management tools, but without all the additional time and work.

PS C:\> Get-SCVMMServer –ComputerName SCVMM1

If you have created a PowerShell profile, you can put the above commands into the profile, so that every time you open the console, the cmdlets are available. I import cmdlets from a SCVMM server and a Hyper-V host, but you can include whatever PowerShell module you need by connecting sessions to those servers and importing the session.

These cmdlets don't truly exist on your computer; they are proxy functions which run on the remote server and not your client. This keeps your performance high and runs the cmdlets on the server that can quickly respond and provide the fastest feedback.

From anywhere in the world, on any computer, you can quickly have the cmdlets you need to manage SCVMM.

Dig Deeper on Microsoft Hyper-V management