Exportar (0) Imprimir
Expandir Tudo

Hyper-V Automation Overview

Atualizado: fevereiro de 2012

Aplica-se a: Windows Server 2012

Windows PowerShell is the scripting solution for automating tasks in Windows Server. However, in current versions of Hyper-V, writing scripts for Hyper-V with in-box tools requires users to learn Windows Management Instrumentation (WMI). WMI provides a very flexible set of interfaces, but they are designed for developers, not IT pros. Hyper-V in Windows Server 2012 addresses this issue by introducing more than 140 built-in Hyper-V cmdlets for Windows PowerShell. Administrators can use these new cmdlets to more easily enable automation of datacenter tasks that range from basic to complex.

The new Hyper-V cmdlets for Windows PowerShell provide IT pros with an easy way to enable automation of management tasks within Windows Server 2012. With the extensive number of Hyper-V cmdlets and the close integration with other parts of the operating system, administrators can now easily enable automation of Hyper-V-related tasks in their environment.

To try out the Hyper-V cmdlets, you will need the following:

  • A computer running Windows Server 2012 with the Hyper-V role installed. Hyper-V requires a computer that has processor support for hardware virtualization.

  • A user account that is a member of the Administrators group or Hyper-V Administrators group.

Hyper-V cmdlets enable administrators to perform the tasks that are available in the graphical user interface of Hyper-V Manager—as well as a number of tasks that can be done exclusively through the cmdlets in Windows PowerShell.

Windows PowerShell is designed intentionally for IT pros. This design decision is reflected in several ways:

  • Task-oriented interface. Hyper-V cmdlets are designed so that it is easy for IT pros to go from thinking about the task to actually performing the task. The following table shows the task and the associated cmdlet syntax:

 

Task

Windows PowerShell command to perform the task

Create a new virtual machine named “test”

New-VM –Name Test

Get a list of all virtual machines

Get-VM

Create a new virtual hard disk at d:\VHDs\test.vhd

New-VHD –Path D:\VHDs\test.vhd

Start all virtual machines whose name begins with “web”

Start-VM –Name web*

Connect the virtual network adapter on the “test” virtual machine to the “QA” switch.

Connect-VMNetworkAdapter –VMName test –SwitchName QA

  • Use of standard cmdlet verbs. Hyper-V administrators often need to manage more than just Hyper-V. By using the same verbs as other Windows cmdlets, the Hyper-V cmdlets make easier for administrators to extend their existing knowledge of Windows PowerShell. For example, administrators who are familiar with managing services through Windows PowerShell can reuse the same verbs to perform the corresponding tasks on a virtual machine, as shown in the following table:

 

Task

Cmdlet for performing task on a service

Cmdlet for performing task on a virtual machine

Get

Get-Service

Get-VM

Configure

Set-Service

Set-VM

Create

New-Service

New-VM

Start

Start-Service

Start-VM

Stop

Stop-Service

Stop-VM

Restart

Restart-Service

Restart-VM

Suspend

Suspend-Service

Suspend-VM

Resume

Resume-Service

Resume-VM

There are similar examples with other core Windows PowerShell cmdlets as well:

 

Core Windows PowerShell cmdlet

Hyper-V cmdlet

Import-Csv

Import-VM

Export-Csv

Export-VM

Enable-PSRemoting

Enable-VMMigration

Checkpoint-Computer

Checkpoint-VM

Measure-Command

Measure-VM

  • Consistent cmdlet nouns to simplify discoverability. The nouns of the Hyper-V cmdlets are designed to make it easier for administrators to discover the cmdlets they need when they need them. All cmdlets in the Hyper-V module use one of three following noun prefixes:

 

Prefix

Purpose

VM

Cmdlets for managing virtual machines

VHD

Cmdlets for managing virtual hard disk files

VFD

Cmdlets for managing virtual floppy disk files

Isso foi útil para você?
(1500 caracteres restantes)
Agradecemos os seus comentários

Contribuições da comunidade

ADICIONAR
A Microsoft está realizando uma pesquisa online para saber sua opinião sobre o site do MSDN. Se você optar por participar, a pesquisa online lhe será apresentada quando você sair do site do MSDN.

Deseja participar?
Mostrar:
© 2014 Microsoft