Cluster Shared Volume Info

$Cluster = "XXX"
$csvdata = Get-ClusterSharedVolume -cluster $Cluster
$csvs = @()
foreach ( $csvitem in ($csvdata))
{
   $cimSession = New-CimSession -ComputerName $csvitem.OwnerNode
   $DiskInfo = Get-Disk -CimSession $cimSession 
   $volumeInfo = $DiskInfo | Get-Partition | Select DiskNumber, @{Name="Volume";Expression={Get-Volume -Partition $_ | Select -ExpandProperty ObjectId}}
   $csvVolume = $csvitem.SharedVolumeInfo.Partition.Name
   $csvdisknumber = ($volumeinfo | ? { $_.Volume -eq $csvVolume}).Disknumber
   $DiskID = ($DiskInfo | where {$_.Number -eq $csvdisknumber}).UniqueId
   $csvinfo = $csvitem | select -Property Name -ExpandProperty SharedVolumeInfo
   $csv = [pscustomobject] [ordered]@{
        Name        = $csvitem.Name
        OwnerNode   = $csvitem.OwnerNode
        Path        = $csvinfo.FriendlyVolumeName
        Size        = [int]($csvinfo.Partition.Size /1GB)
        FreeSpace   = [int]($csvinfo.Partition.FreeSpace /1GB)
        UsedSpace   = [int]($csvinfo.Partition.UsedSpace /1GB)
        PercentFree = [int]$csvinfo.Partition.PercentFree
        DiskID      = $DiskId
    }
    $csvs += $csv   
}
$csvs | sort Freespace

Name : CSVxx_LUNyy
OwnerNode : HVHOST-XXX
Path : C:\ClusterStorage\Volume21
Size : 4096
FreeSpace : 1743
UsedSpace : 2353
PercentFree : 43
DiskID : 60060E801652EE00000152EE00000090

SCVMM error : 23351 : The input string “” for the FirstBootDevice parameter cannot be parsed and may be invalid.

After importing an exported Generation 2 template in VMM, the following error occurs when trying to deploy :
The input string “” for the FirstBootDevice parameter cannot be parsed and may be invalid.
Make sure the string uses one of the following formats: “SCSI,BusId(integer),LunId(integer)” or “NIC,SlotId(integer)”
ID: 23351

This can be fixed up in Powershell like this :

Import-Module virtualmachinemanager
Get-SCVMTemplate -Name 'TEMPLATEXXX'  | Set-SCVMTemplate -FirstBootDevice 'SCSI,0,0'

Get SCVMM DHCP Server Agent version

import-module virtualmachinemanager
$VMMServer = $env:Computername
$Sb = { Get-WmiObject -Class win32_product | where {$_.Name -like “Microsoft System Center Virtual Machine Manager DHCP Server*” } | select Version }
Invoke-Command -ComputerName (get-scvmhost -VMMServer $VMMServer).Name -ScriptBlock $sb | select PScomputerName, Version | ft -AutoSize 

PSComputerName Version
————– ——-
XXX-01.xxx.yyy 3.2.8071.0
XXX-03.xxx.yyy 3.2.8071.0

Unable to bring cloned LUN online in cluster

After using NAS/SAN to restore/clone a LUN, you might be unable to bring it online. Using diskpart to clear it like this :

DISKPART> Select disk 5
DISKPART>attrib disk clear readonly
DISKPART> Failed to clear disk attributes.

This can be caused by duplicate disk ID, in this case Disk 5 is a clone of Disk 3 :

DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 465 GB 1024 KB
Disk 1 Reserved 435 GB 0 B *
Disk 2 Reserved 700 GB 1024 KB *
Disk 3 Reserved 450 GB 0 B *
Disk 4 Reserved 10 GB 1024 KB
Disk 5 Reserved 450 GB 0 B *

DISKPART> select disk 5
Disk 5 is now the selected disk.
DISKPART> uniqueid disk
Disk ID: {2D6F9758-E08C-4FB4-B8EA-868695BBCBE3}
DISKPART> select disk 3
Disk 3 is now the selected disk.
DISKPART> uniqueid disk
Disk ID: {2D6F9758-E08C-4FB4-B8EA-868695BBCBE3}

Since the disk cannot be brought online cause of the duplicate ID, the solution is to do it on a different server, where there is no duplicate disk ID.

Detach the disk on the cluster setup.
Attach it on the new server.
Use Powershell to generate a new ID :
PS C:\> [guid]::NewGuid()
fb0b17eb-4c4f-445c-8888-9f2538b0c61d (it doesn’t matter GUID is lowercase)
Run diskpart :

DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 60 GB 0 B
Disk 1 Online 600 GB 0 B *
Disk 2 Online 450 GB 0 B *
DISKPART> select disk 2
Disk 2 is now the selected disk.
DISKPART> uniqueid disk
Disk ID: {2D6F9758-E08C-4FB4-B8EA-868695BBCBE3}
DISKPART> uniqueid disk ID=fb0b17eb-4c4f-445c-8888-9f2538b0c61d using the new ID generated with Powershell.

DISKPART> uniqueid disk
Disk ID: {FB0B17EB-4C4F-445C-8888-9F2538B0C61D}

Detach the disk from this server, reattach to cluster nodes.

In diskpart run :

DISKPART> rescan
Please wait while DiskPart scans your configuration…
DiskPart has finished scanning your configuration.
DISKPART> select disk 5
Disk 5 is now the selected disk.
DISKPART> uniqueid disk
Disk ID: {FB0B17EB-4C4F-445C-8888-9F2538B0C61D}
DISKPART> attributes disk

Current Read-only State : Yes
Read-only : Yes
Boot Disk : No
Pagefile Disk : No
Hibernation File Disk : No
Crashdump Disk : No
Clustered Disk : Yes

DISKPART> attributes disk clear readonly
Disk attributes cleared successfully.

You should now be able to add the disk in the cluster.

Clear “Redirected Access” stuck state from Hyper-V failover cluster

Run Diskshadow.exe on all cluster nodes
List Shadows all
On the node(s) where shadows are listed, run this :
Delete Shadows All
Run following from Powershell :
Import-Module failoverclusters
Test-ClusterResourceFailure “Cluster Disk 3”
Warning : This will cause a temporary loss of access to the CSV, so VM’s running from it can crash !