Export (0) Print
Expand All

About Windows PowerShell for Virtual Machine Manager

Updated: October 21, 2008

Applies To: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2, Virtual Machine Manager 2008 R2 SP1

In the Windows PowerShell - Virtual Machine Manager command shell, you can perform all System Center Virtual Machine Manager (VMM) administrative functions by using commands or by using task-based scripts. This topic explains the relationship between Windows PowerShell and VMM.

How Virtual Machine Manager Uses Windows PowerShell

Windows PowerShell and VMM provide cmdlets that you can use separately to perform simple administrative tasks. Or, you can combine the cmdlets in commands to perform complex tasks.

The VMM command shell includes all the standard Windows PowerShell cmdlets and a comprehensive set of cmdlets that are designed specifically for VMM. You can use these cmdlets to manage all the actions in a VMM environment, including the following actions:

  • Adding and working with virtual machine hosts and host groups

  • Adding the VMM library and maintaining the resources that it stores

  • Creating and working with virtual machines that are deployed on a host or that are stored in the library

  • Managing the virtual machine environment

  • Creating virtual machine checkpoints

  • Backing up and restoring the VMM database

Windows PowerShell and VMM differentiate between commands and cmdlets as follows:

  • Cmdlet. A cmdlet is a task-oriented command that is used in the Windows PowerShell environment. A cmdlet contains a verb-noun pair that is separated by a dash. The verb acts on a Windows PowerShell object (the noun).

    Most cmdlets are simple, but they are designed to work in combination with other cmdlets. For example, cmdlets that contain the Get verb retrieve data. Cmdlets that contain the Set verb specify or change data.

    The following cmdlet is an example of a VMM cmdlet:

    Get-VMCheckPoint

  • Command. A command might include one or more cmdlets. A command might also contain one or more cmdlet parameters and other elements. However, a command does not have to include a cmdlet. For example, the 2+2 command does not include a cmdlet. And, commands that assign a value or an array of values to a variable, such as $IntegerArray = @(0,1,2,3,4,5,6,7,8,9), do not include a cmdlet. However, a command that assigns a value to a variable often does include a cmdlet. For example, the following command that assigns a value to a variable does include a cmdlet:

    $Credential = Get-Credential

    A command can use the pipeline operator (|) to pass the output of one cmdlet to another cmdlet.

    The following VMM command illustrates how to use the pipeline operator to pass the output of the Get-VMCheckpoint cmdlet to the Restore-VMCheckpoint cmdlet:

    Get-VMCheckpoint -MostRecent –vm "VM01" | Restore-VMCheckpoint

Customers who have installed VMM can access both standard Windows PowerShell cmdlets and VMM cmdlets in the VMM command shell. Windows PowerShell command-line Help for the standard Windows PowerShell cmdlets is provided with Windows Server 2008. The command-line Help for VMM cmdlets is provided with VMM.

How the VMM Administrator Console Uses Virtual Machine Manager Cmdlets

The VMM Administrator Console is built on Windows PowerShell. The following synopsis of the standard call sequence for a hypothetical VMM Administrator Console operation illustrates the integration of Windows PowerShell and the VMM Administrator Console:

  1. The VMM Administrator Console makes a call to a Windows PowerShell cmdlet.

  2. The Windows PowerShell cmdlet makes a Windows Communication Foundation (WCF) call to the VMM server service.

  3. VMM initiates a job if the operation changes state or is long-running and therefore needs to be audited or monitored asynchronously.

  4. VMM makes calls, as necessary, to read and update the VMM database.

  5. If necessary, VMM makes Windows Remote Management (WinRM) calls to access the remote hosts on which virtual machines are deployed or to access remote library servers on which VMM library resources are stored.

  6. WinRM calls access Windows Management Instrumentation (WMI) methods on VMM hosts or library servers. These WMI methods are included with the operating system or with the VMM agent service.

  7. Some of the WMI methods call the Virtual Server component object model application programming interface (COM API).

How a Snap-in Provides Virtual Machine Manager Cmdlets

Windows PowerShell is installed with a set of built-in snap-ins. These Windows PowerShell snap-ins contain the following items:

  • Providers. The standard Windows PowerShell providers provide access to various data stores in a format that is modeled on the file system interface.

  • Cmdlets. The standard Windows PowerShell cmdlets are available for use with any server product that supports Windows PowerShell, including VMM.

For example, the Microsoft.PowerShell.Core snap-in includes the FileSystem, Registry, Alias, Environment, Function, and Variable providers. It also includes basic cmdlets such as Get-Help, Get-Command, and Get-History.

To list the installed Windows PowerShell snap-ins

  1. On a VMM server on which the VMM Administrator Console is installed, click Start, click All Programs, click Microsoft System Center, click Virtual Machine Manager 2008, and then click Windows PowerShell – Virtual Machine Manager.

  2. Type the following command to list the installed snap-ins:

    Get-PSSnapin

  3. Review the command output. The list should include the following entry for VMM:

    Microsoft.SystemCenter.VirtualMachineManager
    

To list all cmdlets

  • Type the following command:

    Get-Command

To list only the Virtual Machine Manager cmdlets

  1. Type the following command:

    Get-Command -PSSnapin Microsoft.SystemCenter.VirtualMachineManager

  2. Confirm that the output lists the VMM cmdlets. The first cmdlet listed is Add-LibraryServer and the last cmdlet is Update-VMMManagedComputer.

How WMI Enables Cross-Product Scripting

VMM uses Windows Management Instrumentation (WMI) for cross-product scripting. WMI is the Microsoft implementation of Web-Based Enterprise Management (WBEM), an industry-wide standard technology for accessing information about components of Windows-based computers in an enterprise environment.

A WMI interface provides programmatic access to a system so users can write command-line administration scripts and tools. Additionally, the WMI interface lets network administrators collect and set configuration details on a wide variety of hardware, operating system components and subsystems, and software.

WMI does not consolidate the management data in a central location.

For more information about how to use WMI, see Accessing WMI from Windows PowerShell (http://go.microsoft.com/fwlink/?LinkId=98347).

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft