Create a gist now

Instantly share code, notes, and snippets.

The Rename-ClusterResource.ps1 script will rename all cluster disks in a Failover Cluster based on the name of the underlying disk volume.
$ClusterDisks = Get-CimInstance -ClassName MSCluster_Resource -Namespace root/mscluster -Filter "type = 'Physical Disk'"
foreach ($Disk in $ClusterDisks) {
$DiskResource = Get-CimAssociatedInstance -InputObject $Disk -ResultClass MSCluster_DiskPartition
if (-not ($DiskResource.VolumeLabel -eq $Disk.Name)) {
Invoke-CimMethod -InputObject $Disk -MethodName Rename -Arguments @{newName = $DiskResource.VolumeLabel}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment