The evolution of Microsoft System Center
A comprehensive collection of articles, videos and more, hand-picked by our editors
PowerShell offers significant support for automation and scripting, but many admins still rely on the SCVMM 2012...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
SP1 graphical management tool to perform repetitive tasks. The Microsoft SCVMM team outfitted PowerShell with 529 cmdlets for every SCVMM management task you need to perform. Beyond automation, managing SCVMM with PowerShell also gives you the ability to create disaster recovery scripts to remove human error and to build your own customized tools. These skills are important additions to an IT pro's tool belt.
Managing SCVMM with PowerShell can be confusing and daunting, but don't let the number of cmdlets and the lengthy help files deter you. Let's discover and learn just what you need to get started and effectively manage tasks.
An overview of SCVMM PowerShell cmdlets
If you're new to PowerShell, or just new to managing SCVMM 2012 SP1 with PowerShell, start with a list of the available cmdlets. Before you run out and start searching for a cmdlet reference, remember that the PowerShell console gives you everything you need.
Start by importing the Virtual Machine Manager (VMM) module containing all the cmdlets, and get a list of commands. You can do this on any computer with SCVMM management tools installed.
PS> Import-Module VirtualMachineManager
PS> Get-Command -Module VirtualMachineManager
Then measure the list to see the number of available commands.
PS> Get-Command -Module VirtualMachineManager | Measure-Object
The list is long and does not help you easily find the commands for a particular task; you'll need to narrow the list to quickly find what you need.
Searching for exactly what you need
PowerShell includes a search capability for commands that help you accomplish a particular task. For example, if you want to manage processes on your computer, use the Get-Help cmdlet to show the available commands.
PS> Get-Help –Name *Process*
More resources on PowerShell capabilities
Using PowerShell for VDI
Enable remoting in PowerShell
Guide to PowerShell scripting in VMware ESX
You'll see a list of five cmdlets: Get-, Start-, Stop-, Wait- and Debug-. If you wanted to stop a process, you would now know the cmdlet name. For more information and for help on how the cmdlet works, its syntax and examples of usage, use the following script:
PS> Get-Help Stop-Process –Full
It's easier to search for cmdlets when you keep the noun -- what it is you want to change or view -- in mind. You can apply this concept to SCVMM. If you need to get information about a VM host or make changes to a VM Host, try this search:
PS> Get-Help *VMHost*
This returns a long list of cmdlets, including many you don't need, such as VMHostConfig, VMHostCluster, VmHostNetworkAdapter. You can narrow the focus by controlling wildcard characters, which produces a better result:
PS> Get-Help *VMHost
The bottom line: If you know the management task you're trying to accomplish, search for the noun using Get-Help. When you find the cmdlet you think will work, examine the entire help file and check the examples.
By searching and discovering the cmdlets you need when you need them, you can immediately start solving problems and managing tasks in SCVMM without having to memorize the entire mountain of cmdlets.
Getting the big picture
The ability to see all cmdlets that a module provides increases your awareness of the management tasks you can automate or script. By default, the long list of commands is sorted by name, which means all verbs are grouped together. I find it helps to organize the list by noun and see the cmdlet name along with a brief description of what it does.
In the example below, I grabbed all the commands from the VMM module, sorted them by noun and sent that list to Get-Help to retrieve the descriptions. This makes it easier to find the cmdlets that will help me with a particular management task. You can use this process with all modules, not just the VMM module.
PS> Get-Command -Module VirtualMachineManager | Sort-Object -Property noun | Get-Help | Select-Object -Property Name, Synopsis
I also find this list easier to view in a graphical grid or even as a Web page on one of my Web servers for quick review. The following shows you how to make a quick graphical view and store the list as a Web page.
PS> Get-Command -Module VirtualMachineManager | Sort-Object -Property noun | Get-Help | Select-Object -Property Name, Synopsis | Out-Gridview
PS> Get-Command -Module VirtualMachineManager | Sort-Object -Property noun | Get-Help | ConvertTo-HTML -Property Name, Synopsis | Out-File c:\CmdList.htm
This list shows me which management tasks I can accomplish with the VMM cmdlets.
Managing SCVMM 2012 with PowerShell may seem like a huge undertaking at first, but PowerShell's built-in search capabilities and Get-Help command simplify the process. They make it easier to see all the automation and scripting possibilities that the module provides.
Jason Helmick asks:
How do you perform SCVMM management tasks?
0 ResponsesJoin the Discussion