Hyper-V Cmdlets in Windows PowerShell

Windows PowerShell® 是基于任务的命令行 shell 和脚本语言,专为系统管理而设计。本参考主题面向信息技术 (IT) 专业人员,可在利用 Windows PowerShell cmdlet 编写脚本和对任务实施自动化时提供协助。

Hyper-V

This reference provides cmdlet descriptions and syntax for all Hyper-V-specific cmdlets. It lists the cmdlets in alphabetical order based on the verb at the beginning of the cmdlet.

cmdlet Description

Add-VMDvdDrive

Installs a DVD drive in a virtual machine (VM).

Add-VMFibreChannelHba

Installs a virtual Fibre Channel host bus adapter in a virtual machine (VM).

Add-VMHardDiskDrive

Installs a hard disk drive in a virtual machine (VM).

Add-VMMigrationNetwork

Adds a network to the list of networks that can be used for virtual machine (VM) migration.

Add-VMNetworkAdapter

Installs a network adapter in a virtual machine (VM).

Add-VMNetworkAdapterAcl

Creates an access control list (ACL) to apply to the traffic sent or received by a virtual machine (VM) network adapter.

Add-VMNetworkAdapterExtendedAcl

Creates an extended ACL for a virtual network adapter.

Add-VmNetworkAdapterRoutingDomainMapping

Adds a routing domain and virtual subnets to a virtual network adapter.

Add-VMRemoteFx3dVideoAdapter

Installs a RemoteFX video adapter in a virtual machine (VM).

Add-VMScsiController

Installs a SCSI controller in a virtual machine (VM).

Add-VMStoragePath

Adds a path to a storage resource pool.

Add-VMSwitch

Adds a network to a resource pool.

Add-VMSwitchExtensionPortFeature

Adds a flow sheet document (FSD) to a virtual network adapter in a virtual machine or the management operating system (which runs the Hyper-V role).

Add-VMSwitchExtensionSwitchFeature

Adds a flow sheet document (FSD) to a virtual switch.

Checkpoint-VM

Creates a checkpoint of a virtual machine (VM).

Compare-VM

Compares a virtual machine (VM) to a host and returns a compatibility report.

Complete-VMFailover

Completes the failover process of the virtual machine (VM).

Connect-VMNetworkAdapter

Connects a virtual network adapter to a virtual network.

Connect-VMSan

Associates a host bus adapter with a virtual storage area network (VMSAN).

Convert-VHD

Converts the format version and type of virtual hard disk file of a virtual machine (VM).

Copy-VMFile

Copies a file to a virtual machine.

Debug-VM

Debugs a virtual machine.

Disable-VMEventing

Disables virtual machine eventing.

Disable-VMIntegrationService

Disables an integration service on a virtual machine (VM).

Disable-VMMigration

Disables migration on one or more virtual machine hosts.

Disable-VMRemoteFXPhysicalVideoAdapter

Disables a particular RemoteFX physical graphics processing unit (GPU) adapter for use with a RemoteFX virtual machine (VM).

Disable-VMResourceMetering

Disables resource utilization data collection for a virtual machine (VM) or a resource pool.

Disable-VMSwitchExtension

Disables one or more extensions —and the feature sets associated with each extension— for one or more specified switches.

Disconnect-VMNetworkAdapter

Disconnects a virtual network adapter from a virtual network or a network resource pool.

Disconnect-VMSan

Removes a host bus adapter from a virtual storage area network (VMSAN).

Dismount-VHD

Specifies the path to the files representing the virtual hard disks to be dismounted.

Enable-VMEventing

Enables the automatic refresh of Hyper-V objects —"live" objects— for the current Windows PowerShell session.

Enable-VMIntegrationService

Enables an integration service on a virtual machine (VM).

Enable-VMMigration

Enables migration on one or more Hyper-V hosts.

Enable-VMRemoteFXPhysicalVideoAdapter

Enables one or more RemoteFX physical video adapters for use with RemoteFX-enabled virtual machines.

Enable-VMReplication

Enables replication of a virtual machine.

Enable-VMResourceMetering

Enables the collection of resource utilization data for one or more virtual machines (VM) or resource pools.

Enable-VMSwitchExtension

Enables one or more extensions —and the feature sets associated with each extension— on one or more specified virtual switches.

Export-VM

Exports a virtual machine (VM) to disk.

Export-VMSnapshot

Exports a checkpoint as a virtual machine (VM) and writes it to disk.

Get-VHD

Creates a VHDObject for each virtual hard disk file specified by path or associated with a virtual machine (VM).

Get-VM

Retrieves a VMObject for each virtual machine (VM) on the Hyper-V host.

Get-VMBios

Retrieves the BIOS configuration of a virtual machine (VM).

Get-VMComPort

Retrieves a list of the COM ports associated with a virtual machine (VM).

Get-VMConnectAccess

Retrieves a list of users that have access to connect to a virtual machine (VM).

Get-VMDvdDrive

Retrieves a list of DVD drives that are attached to a virtual machine (VM).

Get-VMFibreChannelHba

Retrieves a list of all Fibre Channel host bus adapters associated with a virtual machine (VM).

Get-VMFirmware

Gets the firmware configuration of a virtual machine.

Get-VMFloppyDiskDrive

Retrieves a list of floppy disk drives that are attached to a virtual machine (VM).

Get-VMHardDiskDrive

Retrieves a list of the hard disk drives that are attached to a virtual machine (VM).

Get-VMHost

Retrieves the configuration of a Hyper-V host.

Get-VMHostNumaNode

Retrieves the NUMA topology of a Hyper-v host.

Get-VMHostNumaNodeStatus

Retrieves a list that associates each virtual machine (VM) with the allocated resources for each NUMA Node on the host.

Get-VMIdeController

Retrieves a list of the IDE controllers associated with a virtual machine (VM).

Get-VMIntegrationService

Retrieves the integration services configuration of a virtual machine (VM).

Get-VMMemory

Retrieves the memory configuration of a virtual machine (VM).

Get-VMMigrationNetwork

Retrieves a list of the networks that have been added for migration on a Hyper-V host.

Get-VMNetworkAdapter

Retrieves a list of the virtual network adapters of a virtual machine (VM), the management operating system, or both.

Get-VMNetworkAdapterAcl

Retrieves an access control list (ACL) configured for a virtual machine (VM) network adapter.

Get-VMNetworkAdapterExtendedAcl

Gets extended ACLs configured for a virtual network adapter.

Get-VMNetworkAdapterFailoverConfiguration

Retrieves the Failover IP settings on a virtual machine (VM) network adaptor.

Get-VmNetworkAdapterIsolation

Gets isolation settings for a virtual network adapter.

Get-VMNetworkAdapterRoutingDomainMapping

Gets members of a routing domain.

Get-VMNetworkAdapterVlan

Retrieves virtual local area network (VLAN) settings configured on a virtual network adapter.

Get-VMProcessor

Retrieves the processor configuration of a virtual machine (VM).

Get-VMRemoteFx3dVideoAdapter

Retrieves the RemoteFX adapter of a virtual machine (VM).

Get-VMRemoteFXPhysicalVideoAdapter

Retrieves a list of physical graphics processing unit (GPU) adapters in the server that can be used with RemoteFX.

Get-VMReplication

Retrieve a list of virtual machine (VM) replication plans or a specific replication plan and associated settings.

Get-VMReplicationAuthorizationEntry

Retrieve the authorization list or a specific authorization entry.

Get-VMReplicationServer

Retrieves the authentication details of the recovery server.

Get-VMResourcePool

Retrieves the resource pools that meet the specified criteria.

Get-VMSan

Retrieves a list of virtual storage area networks (VMSANs) available on a host.

Get-VMScsiController

Retrieves the virtual SCSI controllers for a virtual machine (VM).

Get-VMSnapshot

Retrieves a list of the checkpoints of a virtual machine (VM).

Get-VMStoragePath

Retrieves a list of the paths in a storage resource pool.

Get-VMSwitch

Retrieves the virtual network from a virtual machine (VM) host.

Get-VMSwitchExtension

Retrieves a list of the switch extensions on one or more virtual switches.

Get-VMSwitchExtensionPortData

Retrieves the status or the statistics for the extension of a virtual switch (VMSwitch) applied on a virtual network adapter.

Get-VMSwitchExtensionPortFeature

Retrieve features configured on a virtual network adapter.

Get-VMSwitchExtensionSwitchData

Retrieves the status or the statistics for the extension of a virtual switch (VMSwitch) applied on a VMSwitch.

Get-VMSwitchExtensionSwitchFeature

Retrieves features configured on a virtual switch (VMSwitch).

Get-VMSystemSwitchExtension

Retrieves a list of the switch extensions that are installed on a physical server at a system level.

Get-VMSystemSwitchExtensionPortFeature

Retrieves the default instance of the port level feature or features available in an extension at a system level.

Get-VMSystemSwitchExtensionSwitchFeature

Retrieves the default instance of the switch level feature or features available in an extension at a system level.

Grant-VMConnectAccess

Grants a user access to connect to a virtual machine (VM).

Import-VM

Imports a virtual machine (VM) from a folder.

Import-VMInitialReplication

Imports the initial replication at a recovery site.

Measure-VM

Retrieves the resource utilization data of virtual machines (VMs).

Measure-VMReplication

Retrieves statistics related to the replication of a virtual machine.

Measure-VMResourcePool

Retrieves the resource utilization information for a resource pool.

Merge-VHD

Merges virtual hard disks (VHDs) in a differencing virtual hard disk (VHD) chain.

Mount-VHD

Mounts one or more virtual hard disks (VHDs) specified by one or more virtual hard disk (VHD) files.

Move-VM

Migrates an offline virtual machine (VM) or Live Migrates a running virtual machine (VM).

Move-VMStorage

Moves the storage of a virtual machine (VM).

New-VFD

Creates a virtual floppy disk.

New-VHD

Creates one or more new virtual hard disk (VHD) files.

New-VM

Creates a new virtual machine (VM).

New-VMReplicationAuthorizationEntry

Creates an authorization entry containing the allowed primary server and corresponding replica storage.

New-VMResourcePool

Creates a resource pool.

New-VMSan

Creates a new virtual storage area network (VMSAN) on a Hyper-V host.

New-VMSwitch

Creates a new virtual network switch on a Hyper-V host.

Optimize-VHD

Compacts one or more dynamic or differencing virtual hard disk (VHD) files.

Remove-VM

Deletes the configuration file for a virtual machine.

Remove-VMDvdDrive

Deletes one or more virtual DVD drives from a virtual machine (VM).

Remove-VMFibreChannelHba

Deletes a Fibre Channel host bus adapter from a virtual machine (VM) configuration.

Remove-VMHardDiskDrive

Deletes one or more virtual hard disks (VHDs) from a virtual machine (VM).

Remove-VMMigrationNetwork

Deletes a network from the list of networks that can be used for virtual machine (VM) migration.

Remove-VMNetworkAdapter

Deletes one or more network adapters from a virtual machine (VM).

Remove-VMNetworkAdapterAcl

Deletes an access control list (ACL) applied to a virtual machine (VM) network adapter for traffic that is sent or received.

Remove-VMNetworkAdapterExtendedAcl

Removes an extended ACL for a virtual network adapter.

Remove-VMNetworkAdapterRoutingDomainMapping

Removes a virtual subnet from a routing domain.

Remove-VMRemoteFx3dVideoAdapter

Deletes a RemoteFX adapter from a virtual machine (VM).

Remove-VMReplication

Delete the replication relationship for a virtual machine.

Remove-VMReplicationAuthorizationEntry

Deletes an authorization entry.

Remove-VMResourcePool

Deletes a resource pool.

Remove-VMSan

Deletes a virtual storage area network (VMSAN) from a Hyper-V host.

Remove-VMSavedState

Deletes the saved state of a saved virtual machine (VM).

Remove-VMScsiController

Deletes one or more SCSI controllers from a virtual machine (VM).

Remove-VMSnapshot

Deletes a checkpoint or checkpoint tree.

Remove-VMStoragePath

Deletes a path from a virtual machine (VM) storage resource pool.

Remove-VMSwitch

Deletes a virtual network.

Remove-VMSwitchExtensionPortFeature

Deletes a flow sheet document (FSD) from a virtual network adapter.

Remove-VMSwitchExtensionSwitchFeature

Deletes a flow sheet document (FSD) from a virtual switch.

Rename-VM

Renames a virtual machine (VM).

Rename-VMNetworkAdapter

Renames a virtual network adapter on a virtual machine or on the management operating system.

Rename-VMResourcePool

Renames a resource pool.

Rename-VMSan

Renames an existing virtual machine storage area network (VMSan).

Rename-VMSnapshot

Renames a checkpoint.

Rename-VMSwitch

Renames a virtual network.

Repair-VM

Restores one or more virtual machines (VMs) to usable condition based upon adjustments ─fixes─ contained in each compatibility report.

Reset-VMReplicationStatistics

Resets the data collected about resource utilization for a virtual machine (VM) or a resource pool.

Reset-VMResourceMetering

Resets the resource utilization data collected by Hyper-V resource metering.

Resize-VHD

Resize a virtual hard disk (VHD).

Restart-VM

Restarts a virtual machine (VM) immediately with shutting down the operating system.

Restore-VMSnapshot

Restores a virtual machine (VM) checkpoint.

Resume-VM

Resumes a paused (suspended) or saved (hibernated) virtual machine (VM).

Resume-VMReplication

Resumes the replication of a virtual machine (VM).

Revoke-VMConnectAccess

Revokes the access assigned to a user for connections to a virtual machine (VM).

Save-VM

Saves a virtual machine (VM).

Set-VHD

Modifies the differencing virtual hard disk (VHD) chain settings to assign the parent of a virtual hard disk file (VHD).

Set-VM

Modifies the properties for a virtual machine (VM).

Set-VMBios

Modifies the BIOS settings of a virtual machine (VM).

Set-VMComPort

Modifies the virtual COM port settings for a virtual machine (VM).

Set-VMDvdDrive

Modifies the virtual DVD drive settings for a virtual machine (VM).

Set-VMFibreChannelHba

Modifies the existing Fibre Channel host bus adapter settings for a virtual machine (VM).

Set-VMFirmware

Sets the firmware configuration of a virtual machine.

Set-VMFloppyDiskDrive

Modifies the virtual floppy drive (VFD) settings for a virtual machine (VM).

Set-VMHardDiskDrive

Modifies the virtual hard disk (VHD) drive settings for a virtual machine (VM).

Set-VMHost

Modifies the settings for a Hyper-V host.

Set-VMMemory

Modifies the memory settings for a virtual machine (VM).

Set-VMMigrationNetwork

Sets the subnet, subnet mask, and/or priority of a migration network.

Set-VMNetworkAdapter

Modifies the network adapter settings for a virtual machine (VM).

Set-VMNetworkAdapterFailoverConfiguration

Modifies the Failover IP settings of the network adapter for a virtual machine (VM).

Set-VmNetworkAdapterIsolation

Modifies isolation settings for a virtual network adapter.

Set-VmNetworkAdapterRoutingDomainMapping

Sets virtual subnets on a routing domain.

Set-VMNetworkAdapterVlan

Modifies the virtual local area network (VLAN) settings configured on a virtual machine (VM) network adapter.

Set-VMProcessor

Modifies the virtual processor settings for a virtual machine (VM).

Set-VMRemoteFx3dVideoAdapter

Modifies the RemoteFX adapter settings for a virtual machine (VM).

Set-VMReplication

Modifies the replication relationship settings for a virtual machine (VM).

Set-VMReplicationAuthorizationEntry

Modifies the authorization entry for a virtual machine (VM).

Set-VMReplicationServer

Modifies the settings that specify the server authentication and the associated ports of the recovery server for a virtual machine (VM).

Set-VMResourcePool

Modifies the settings that specify the relationship between two resource pools.

Set-VMSan

Modifies the existing virtual machine storage area network (VMSAN) settings on the Hyper-V host.

Set-VMSwitch

Modifies the virtual network settings for a virtual machine (VM).

Set-VMSwitchExtensionPortFeature

Modifies an existing flow sheet document (FSD) of a virtual machine network interface controller (VMNIC) or parent virtual network interface controller (VNIC) for a virtual machine (VM).

Set-VMSwitchExtensionSwitchFeature

Modifies an existing flow sheet document (FSD) of a vmswitch for a virtual machine (VM).

Start-VM

Intiates a virtual machine (VM) that is shutdown —off—, hibernated —saved—, or suspended —paused—.

Start-VMFailover

Initiates the failover of a virtual machine (VM).

Start-VMInitialReplication

Initiates the replication for a virtual machine (VM).

Stop-VM

Discontinues running an active virtual machine (VM).

Stop-VMFailover

Discontinues an on-going failover for a virtual machine (VM).

Stop-VMInitialReplication

Discontinues an on-going replication for a virtual machine (VM).

Stop-VMReplication

Discontinues an on-going resync operation for a virtual machine (VM).

Suspend-VM

Pauses an active virtual machine (VM).

Suspend-VMReplication

Pauses replication for a virtual machine (VM).

Test-VMReplicationConnection

Tests the connection configured for replication traffic.

Test-VHD

Verifies the usability of one of more virtual hard disk (VHD) files.

备注

To view a list all the cmdlets that are available for Hyper-V, run the Get-Command -Module Hyper-V command.

有关任何 cmdlet 或其语法的详细信息,请使用 Get-Help <cmdlet 名称> cmdlet,其中 *<cmdlet 名称>*是你要搜索的 cmdlet 的名称。若需了解详细信息,可以运行以下任一 cmdlet:

Get-Help <cmdlet 名称> -Detailed
Get-Help <cmdlet 名称> -Examples
Get-Help <cmdlet 名称> -Full