Partager via


Configuring Cluster Shared Volumes and Clustered Virtual Machines by Using Windows PowerShell

Updated: October 1, 2009

Applies To: Windows Server 2008 R2

This topic lists common tasks related to configuring Cluster Shared Volumes and clustered virtual machines on a failover cluster running Windows Server 2008 R2, and shows example Windows PowerShell commands for performing those tasks. The Windows PowerShell cmdlets provide an alternative interface for actions that you might otherwise perform with command-line commands or the Failover Cluster Manager snap-in. For topics that list other common tasks and the corresponding Windows PowerShell commands, see Performing Common Tasks in a Failover Cluster by Using Windows PowerShell.

For more information about how to use Windows PowerShell, see Additional references, later in this topic.

Common tasks and example commands for working with Cluster Shared Volumes

This section lists common tasks for working with Cluster Shared Volumes, and the example Windows PowerShell commands for performing those tasks. Also see Common tasks and example commands for working with clustered virtual machines, later in this topic.

Note

This topic includes commands for failover cluster disks that are in Cluster Shared Volumes. For information about commands for other disks in a failover cluster, see Configuring Existing Failover Cluster Disks by Using Windows PowerShell.

Task PowerShell command

Review the status of Cluster Shared Volumes.

Get-ClusterSharedVolume

For more information, see Get-ClusterSharedVolume (https://go.microsoft.com/fwlink/?LinkId=143797).

Review properties of a Cluster Shared Volume.

Get-ClusterSharedVolume "Cluster Disk 2" | Get-ClusterParameter

Where Cluster Disk 2 is the Cluster Shared Volume for which you want to review properties.

Or:

Get-ClusterSharedVolume "Cluster Disk 2" | fc *

Where Cluster Disk 2 is the Cluster Shared Volume for which you want to review properties.

For more information, see:

Turn maintenance for a disk on and off.

Suspend-ClusterResource "Cluster Disk 5"

Resume-ClusterResource "Cluster Disk 5"

Where Cluster Disk 5 is the disk on which you are turning on maintenance (suspending the resource) and turning off maintenance (resuming the resource).

Or:

Suspend-ClusterResource "Cluster Disk 5" -VolumeName "C:\ClusterStorage\Volume2"

Resume-ClusterResource "Cluster Disk 5" -VolumeName "C:\ClusterStorage\Volume2"

Where Volume2 is the individual volume (in this example, on Cluster Disk 5) on which you are turning on maintenance (suspending the resource) and turning off maintenance (resuming the resource). You can specify the volume name with or without including the path (in this example, C:\ClusterStorage\) in the name.

For more information, see:

Run "chkdsk /f" on a Cluster Shared Volume.

(Runs on the local node.)

Repair-ClusterSharedVolume C:\ClusterStorage\Volume1 -ChkDsk -Parameters "/F"

Where C:\ClusterStorage\Volume1 is the Cluster Shared Volume on which you want to run chkdsk /f.

For more information, see Repair-ClusterSharedVolume (https://go.microsoft.com/fwlink/?LinkId=143812).

Run "defrag" on a Cluster Shared Volume.

(Runs on the local node.)

Repair-ClusterSharedVolume C:\ClusterStorage\Volume1 -Defrag

Where C:\ClusterStorage\Volume1 is the Cluster Shared Volume on which you want to run defrag.

For more information, see Repair-ClusterSharedVolume (https://go.microsoft.com/fwlink/?LinkId=143812).

Move a Cluster Shared Volume to a different node.

Move-ClusterSharedVolume "Cluster Disk 3"

Where Cluster Disk 3 is the Cluster Shared Volume you are moving to ownership by a different node.

For more information, see Move-ClusterSharedVolume (https://go.microsoft.com/fwlink/?LinkId=143801).

Common tasks and example commands for working with clustered virtual machines

This section lists common tasks for working with clustered virtual machines, and the example Windows PowerShell commands for performing those tasks. Also see Common tasks and example commands for working with Cluster Shared Volumes, earlier in this topic.

Task PowerShell command

Review status of clustered virtual machines.

Get-ClusterResource | ?{ $_.ResourceType.Name -eq "Virtual Machine" } | Select-Object -Unique OwnerGroup,State

For more information, see:

  • Get-ClusterResource (https://go.microsoft.com/fwlink/?LinkId=143793)

  • Information about Where-Object, represented in the preceding command by ?, the question-mark alias: Where-Object (https://go.microsoft.com/fwlink/?LinkId=113423)

  • Select-Object (https://go.microsoft.com/fwlink/?LinkId=113387)

Review resources in a clustered virtual machine.

Get-ClusterGroup "VM1" | Get-ClusterResource

Where VM1 is a clustered virtual machine that contains resources whose status you want to review.

For more information, see:

Live migrate a clustered virtual machine.

(This also tests failover.)

Move-ClusterVirtualMachineRole "VM1" -Node node2

Where VM1 is a clustered virtual machine that you want to live migrate or test, and node2 is the node to which you want to live migrate the clustered virtual machine.

For more information, see Move-ClusterVirtualMachineRole (https://go.microsoft.com/fwlink/?LinkId=143802).

Quick migrate a clustered virtual machine.

(This also tests failover.)

Move-ClusterGroup "VM1"

Where VM1 is a clustered virtual machine that you want to quick migrate or test, and that has an OfflineAction setting of 1.

For more information, see Move-ClusterGroup (https://go.microsoft.com/fwlink/?LinkId=143799). Also see the next item for information about OfflineAction.

Review OfflineAction settings for clustered virtual machines.

Get-ClusterResource | ?{$_.ResourceType.Name -eq "Virtual Machine"} | Get-ClusterParameter OfflineAction

The OfflineAction setting affects the action the cluster takes when you move the clustered virtual machine from one node to another. The default for OfflineAction is 1, which saves the state of the virtual machine.

For more information, see:

  • Get-ClusterResource (https://go.microsoft.com/fwlink/?LinkId=143793)

  • Information about Where-Object, represented in the preceding command by ?, the question-mark alias: Where-Object (https://go.microsoft.com/fwlink/?LinkId=113423)

  • Get-ClusterParameter (https://go.microsoft.com/fwlink/?LinkId=143791)

  • OfflineAction (https://go.microsoft.com/fwlink/?LinkId=160158)

Refresh a clustered virtual machine configuration.

Update-ClusterVirtualMachineConfiguration "Virtual Machine Configuration VM1"

Where Virtual Machine Configuration VM1 is the name of the virtual machine configuration resource for the virtual machine that you want to refresh. You must refresh the configuration of a clustered virtual machine if you use Hyper-V Manager (instead of a failover clustering interface) to change the configuration.

For more information, see Update-ClusterVirtualMachineConfiguration (https://go.microsoft.com/fwlink/?LinkId=143833).

Additional references