Renaming Cluster Available Disk

Hello PS Community,

I am attempting to rename multiple cluster available disk on Windows Server 2022 server. Cluster Available Disk will be added as a mount point inside a single drive.

These are cluster available disk

These are their volume labels because they will not be assigned a drive letter.

Once added inside Failover Cluster as shown below.

Now, I want to rename them in bulk based on their file system label . I cannot find a away to tie together a disk i.e. ‘Cluster Disk X‘ with any other attribute i.e. Disk Number , ID etc. via PowerShell command in such a that If Disk Physical Number is 5 then then its label/name inside Available Cluster Storage should be ‘XXXX’ file system label or match its volume label as shown earlier.

Is there a way to rename in bulk Cluster Available Disk based on its file system label.

There is an Access Modifiers but it is a manual process. I have to manually match ‘Cluster Disk X‘ with Disk Number to assign a label. I have to match physical disk number with ‘‘Cluster Disk X‘ as shown below.

$ClusterDisk1 = Get-ClusterResource -Name ‘Cluster Disk 1’

$ClusterDisk1.Name = ‘AppVol’

But this is a manual and error prone process. I want to rename it in bulk.

It’s surprisingly difficult to map volumes to disk/partition. Here is the best thing I could come up with over the years. (I used to just make best guess effort based on disk capacity)

$diskdrivelist = Get-CimInstance Win32_Diskdrive -Filter "Partitions>0" 

$output = foreach($diskdrive in $diskdrivelist){
    $diskpartitionlist = Get-CimInstance -Namespace "root\cimv2" -Query  "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($diskdrive.deviceid)'} WHERE AssocClass = Win32_DiskDriveToDiskPartition"

    foreach($diskpartition in $diskpartitionlist){
        $logicaldisklist = Get-CimInstance -Namespace "root\cimv2" -Query  "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($diskpartition.DeviceID)'} WHERE AssocClass = Win32_LogicalDiskToPartition"

        foreach($logicaldisk in $logicaldisklist) {
       
            [PSCustomObject]@{
                ComputerName        = $env:COMPUTERNAME
                Date                = (Get-Date).ToString('o')
                Size                = $logicaldisk.Size
                Free                = $logicaldisk.FreeSpace
                Partition           = $diskpartition.Name
                DiskIndex           = $diskpartition.DiskIndex
                DriveLetter         = $logicaldisk.Name
                Description         = $diskdrive.Description
                DeviceID            = $diskdrive.DeviceID
                DeviceModel         = $diskdrive.Model
                FileSystem          = $logicaldisk.FileSystem
                Compressed          = $logicaldisk.Compressed
                VolumeDirty         = $logicaldisk.VolumeDirty
                VolumeName          = $logicaldisk.VolumeName
                VolumeSerialNumber  = $logicaldisk.VolumeSerialNumber
                MediaType           = $diskdrive.MediaType
            }
        }
    }
}

With the limited info you get from the cluster side, I think the Number can be correlated to the DiskIndex of the logical disk. If so, the VolumeName should be what you want to rename it to.

See if this seems to match on your end

$available = Get-ClusterAvailableDisk

foreach($disk in $available){
    $current = $output | where diskindex -eq $disk.number

    Write-Host "Cluster disk '$($disk.Name)' is volume '$($current.VolumeName)'" -ForegroundColor Cyan
}

If so you can grab this info before adding them to the cluster to use for renaming after.

$listwithclustername = foreach($disk in $available){
    $current = $output | where diskindex -eq $disk.number

    $current | Add-Member -NotePropertyName ClusterName -NotePropertyValue $disk.Name
    $current | Add-Member -NotePropertyName ClusterId -NotePropertyValue $disk.Id
    $current | Add-Member -NotePropertyName Partitions -NotePropertyValue $disk.Partitions -PassThru
}

Thanks for your response.

Looking at this section of the script I found that it may not work.

$available = Get-ClusterAvailableDisk

foreach($disk in $available){
    $current = $output | where diskindex -eq $disk.number

    Write-Host "Cluster disk '$($disk.Name)' is volume '$($current.VolumeName)'" -ForegroundColor Cyan
}

I will explain the reason why. Get-ClusterAvailableDisk does not work once I add all disks inside Failover Cluster Manager and If ran again it draws blank. Following output shows disks NOT added into Failover Cluster Manager yet.

PS C:\> Get-ClusterAvailableDisk | Sort-Object Number | FT -AutoSize

Cluster          Id                                   Name            Number        Size Partitions
-------          --                                   ----            ------        ---- ----------
file-server-clst 90cc2033-1c16-4c34-8244-bd97ac54c45b Cluster Disk 8       1  9663676416 {}
file-server-clst ce22258b-7a06-4000-8480-3b7f13319198 Cluster Disk 11      2 11811160064 {}
file-server-clst 59890e9b-ec13-4b96-9375-05d6067b815f Cluster Disk 4       3 13958643712 {}
file-server-clst 7f2e4765-e7db-4e1e-a81e-ecf1b81dac7b Cluster Disk 6       5 16106127360 {}
file-server-clst fb0136a3-bb11-4783-ad65-0056e9d92fc6 Cluster Disk 12      6 18253611008 {}
file-server-clst ab49c0a0-4eeb-4e67-b569-cbd43fff301e Cluster Disk 9       7 20401094656 {}
file-server-clst cd30fa0e-8212-4765-818c-cded6a652617 Cluster Disk 10      9 22548578304 {}
file-server-clst 8b730f5c-f0f0-4836-820b-e3037fdcf601 Cluster Disk 7      10 24696061952 {}
file-server-clst 010b50c3-7258-4e50-8444-c6cbc93a2fc4 Cluster Disk 1      11 26843545600 {}
file-server-clst 27a3f360-71fb-4a97-9b2c-08ebe41a6791 Cluster Disk 2      12  1073741824 {}
file-server-clst 446c0936-5afd-4e32-986e-54b09d474147 Cluster Disk 3      13  7516192768 {}
file-server-clst 6f29f221-2fc0-400f-8fa8-7c6c8fa3c631 Cluster Disk 5      14  5368709120 {}

When I add them into Failover Cluster Manager, they disappear from Get-ClusterAvailableDisk output. It only appears in the following command then

PS C:\> Get-ClusterResource | Sort-Object Name

Name                     State   OwnerGroup        ResourceType
----                     -----   ----------        ------------
Cluster Disk 1           Online  Available Storage Physical Disk
Cluster Disk 10          Online  Available Storage Physical Disk
Cluster Disk 11          Online  Available Storage Physical Disk
Cluster Disk 12          Online  Available Storage Physical Disk
Cluster Disk 2           Online  Available Storage Physical Disk
Cluster Disk 3           Online  Available Storage Physical Disk
Cluster Disk 4           Online  Available Storage Physical Disk
Cluster Disk 5           Online  Available Storage Physical Disk
Cluster Disk 6           Online  Available Storage Physical Disk
Cluster Disk 7           Online  Available Storage Physical Disk
Cluster Disk 8           Online  Available Storage Physical Disk
Cluster Disk 9           Online  Available Storage Physical Disk

Running following command draws blank

Get-ClusterAvailableDisk | Sort-Object Number | FT -AutoSize

Therefore, the snippet I pasted in this response cannot work and problem of finding a relationship between Disk number and its association inside following command draws blank too which leads to unable to label disk inside Failover Cluster by matching its Disk number etc.

Get-ClusterResource | Sort-Object Name

I hope that I am able to communicate my understanding . :slight_smile:

I said you have to do this before adding them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.