Author Posts

July 17, 2018 at 7:36 am

Hello all,

I comme back here because apparently there isnt native cmdlet to have this informations in a Cluster FailOver :
– Name of the disk like "Cluster disk 1"
– Size of the disk "Cluster disk 1"

After some research on the net i've found a script who give us this information, but i dont understand all.
And in the script he have "SQL Server".
It's possible for me to have this informations without sql server ?

script :

  $clusters = Get-Cluster -Domain $env:USERDNSDOMAIN

foreach ($cluster in $clusters.name) {
    $sqlgroups = (Get-ClusterResource -cluster $cluster | Where-Object ResourceType -eq 'SQL Server')
    if ($sqlgroups  -ne $null) {
		foreach ($sqlgroup in $sqlgroups) {
			$sqlserver = Get-WmiObject -namespace root\MSCluster MSCluster_Resource -filter "Name='$sqlgroup'" -computername $cluster -Authentication PacketPrivacy
			$resourcegroup = $sqlserver.GetRelated() | Where Type -eq 'Physical Disk'
			
			foreach ($resource in $resourcegroup) {
				$disks = $resource.GetRelated("MSCluster_Disk")
				foreach ($disk in $disks) {
					$diskpart = $disk.GetRelated("MSCluster_DiskPartition") 
					$clusterdisk = $resource.name
					$diskstate = $resource.state
					$diskdrive = $diskpart.path
					$disklabel = $diskpart.volumelabel
					$disksize = $diskpart.totalsize
					$diskfree = $diskpart.freespace

					switch ($diskstate) { 
							-1 { $diskstate = "Unknown"} 
							0   { $diskstate = "Inherited"} 
							1   { $diskstate = "Initializing"} 
							2   { $diskstate = "Online"} 
							3   { $diskstate = "Offline"} 
							4   { $diskstate = "Failed"} 
							128 { $diskstate = "Pending"}
							129 { $diskstate = "Online Pending"} 
							130 { $diskstate = "Offline Pending"} 
					} 

					Write-Host "Cluster: $cluster"
					Write-Host "SQL Resource: $sqlgroup"
					Write-Host "Cluster disk: $clusterdisk"
					Write-Host "Disk State: $diskstate"
					Write-Host "Disk Drive: $diskdrive"
					Write-Host "Disk Label: $disklabel"
					Write-Host "Disk Size: $disksize"
					Write-Host "Disk Free: $diskfree`n" 
				} 
			}
		}
	}
}

I just need of this two informations :

Write-Host "Cluster disk: $clusterdisk"
Write-Host "Disk Size: $disksize"

Thx for replay 😉

July 17, 2018 at 9:08 am

I' ve try some things :

First try :

$x = (Get-WmiObject -namespace root\MSCluster MSCluster_Resource -computername "HyperV1" -Authentication PacketPrivacy)
$y = $x.GetRelated() | Where Type -eq 'Physical Disk'

The result is empty...!?

Without the "$x = ",The result of the first command is that :

 Get-WmiObject -namespace root\MSCluster MSCluster_Resource -computername "HyperV1" -Authentication PacketPrivacy


__GENUS                   : 2
__CLASS                   : MSCluster_Resource
__SUPERCLASS              : MSCluster_LogicalElement
__DYNASTY                 : CIM_ManagedSystemElement
__RELPATH                 : MSCluster_Resource.Name="Adresse IP du cluster"
__PROPERTY_COUNT          : 42
__DERIVATION              : {MSCluster_LogicalElement, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER                  : HYPERV1
__NAMESPACE               : root\MSCluster
__PATH                    : \\HYPERV1\root\MSCluster:MSCluster_Resource.Name="Adresse IP du cluster"
Caption                   : 
Characteristics           : 0
CoreResource              : False
CryptoCheckpoints         : {}
DeadlockTimeout           : 300000
DeleteRequiresAllNodes    : False
Description               : 
EmbeddedFailureAction     : 2
Flags                     : 0
Id                        : 65b5d21b-c218-4de3-bd13-daf3cdb750b9
InstallDate               : 
IsAlivePollInterval       : 4294967295
IsClusterSharedVolume     : False
LastOperationStatusCode   : 0
LocalQuorumCapable        : False
LooksAlivePollInterval    : 4294967295
MonitorProcessId          : 4060
Name                      : Adresse IP du cluster
OwnerGroup                : Groupe du cluster
OwnerNode                 : HyperV2
PendingTimeout            : 180000
PersistentState           : True
PrivateProperties         : System.Management.ManagementBaseObject
QuorumCapable             : False
RegistryCheckpoints       : {}
RequiredDependencyClasses : 
RequiredDependencyTypes   : {}
ResourceClass             : 2
ResourceSpecificData1     : 0
ResourceSpecificData2     : 0
ResourceSpecificStatus    : 
RestartAction             : 2
RestartDelay              : 500
RestartPeriod             : 900000
RestartThreshold          : 1
RetryPeriodOnFailure      : 3600000
SeparateMonitor           : False
State                     : 2
Status                    : 
StatusInformation         : 0
Subclass                  : 
Type                      : IP Address
PSComputerName            : HYPERV1

__GENUS                   : 2
__CLASS                   : MSCluster_Resource
__SUPERCLASS              : MSCluster_LogicalElement
__DYNASTY                 : CIM_ManagedSystemElement
__RELPATH                 : MSCluster_Resource.Name="Disque de cluster 1"
__PROPERTY_COUNT          : 42
__DERIVATION              : {MSCluster_LogicalElement, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER                  : HYPERV1
__NAMESPACE               : root\MSCluster
__PATH                    : \\HYPERV1\root\MSCluster:MSCluster_Resource.Name="Disque de cluster 1"
Caption                   : 
Characteristics           : 2081
CoreResource              : False
CryptoCheckpoints         : {}
DeadlockTimeout           : 300000
DeleteRequiresAllNodes    : False
Description               : 
EmbeddedFailureAction     : 2
Flags                     : 0
Id                        : e4117ba0-9734-48d9-b31f-7227158c73e7
InstallDate               : 
IsAlivePollInterval       : 4294967295
IsClusterSharedVolume     : True
LastOperationStatusCode   : 0
LocalQuorumCapable        : False
LooksAlivePollInterval    : 4294967295
MonitorProcessId          : 4284
Name                      : Disque de cluster 1
OwnerGroup                : 5c574f3a-2ce0-472a-bbec-49e8cadd507c
OwnerNode                 : HyperV1
PendingTimeout            : 180000
PersistentState           : True
PrivateProperties         : System.Management.ManagementBaseObject
QuorumCapable             : True
RegistryCheckpoints       : {}
RequiredDependencyClasses : 
RequiredDependencyTypes   : {}
ResourceClass             : 1
ResourceSpecificData1     : 0
ResourceSpecificData2     : 0
ResourceSpecificStatus    : 
RestartAction             : 2
RestartDelay              : 500
RestartPeriod             : 600000
RestartThreshold          : 1
RetryPeriodOnFailure      : 900000
SeparateMonitor           : False
State                     : 2
Status                    : 
StatusInformation         : 0
Subclass                  : 
Type                      : Physical Disk
PSComputerName            : HYPERV1

__GENUS                   : 2
__CLASS                   : MSCluster_Resource
__SUPERCLASS              : MSCluster_LogicalElement
__DYNASTY                 : CIM_ManagedSystemElement
__RELPATH                 : MSCluster_Resource.Name="Disque de cluster 2"
__PROPERTY_COUNT          : 42
__DERIVATION              : {MSCluster_LogicalElement, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER                  : HYPERV1
__NAMESPACE               : root\MSCluster
__PATH                    : \\HYPERV1\root\MSCluster:MSCluster_Resource.Name="Disque de cluster 2"
Caption                   : 
Characteristics           : 2081
CoreResource              : False
CryptoCheckpoints         : {}
DeadlockTimeout           : 300000
DeleteRequiresAllNodes    : False
Description               : 
EmbeddedFailureAction     : 2
Flags                     : 0
Id                        : 8311eba2-400e-45a2-bc81-6d1ad12cd00e
InstallDate               : 
IsAlivePollInterval       : 4294967295
IsClusterSharedVolume     : True
LastOperationStatusCode   : 0
LocalQuorumCapable        : False
LooksAlivePollInterval    : 4294967295
MonitorProcessId          : 4608
Name                      : Disque de cluster 2
OwnerGroup                : 1d1e36de-bcec-4f92-b3cf-97272060cae1
OwnerNode                 : HyperV2
PendingTimeout            : 180000
PersistentState           : True
PrivateProperties         : System.Management.ManagementBaseObject
QuorumCapable             : True
RegistryCheckpoints       : {}
RequiredDependencyClasses : 
RequiredDependencyTypes   : {}
ResourceClass             : 1
ResourceSpecificData1     : 0
ResourceSpecificData2     : 0
ResourceSpecificStatus    : 
RestartAction             : 2
RestartDelay              : 500
RestartPeriod             : 600000
RestartThreshold          : 1
RetryPeriodOnFailure      : 900000
SeparateMonitor           : False
State                     : 2
Status                    : 
StatusInformation         : 0
Subclass                  : 
Type                      : Physical Disk
PSComputerName            : HYPERV1

And when i try this command

 $y = $x.GetRelated().Type

, i have just this result
PS C:\Windows\system32> $y
Network Name
IP Address

I miss a lot of things , i think...

thx for you're help 😉

July 17, 2018 at 6:06 pm

Hi,

Check out the failoverclusters module, where there is a cmdlet Get-ClusterSharedVolyme that will help you. Pipe it to get-member so you will see what property and methods you can use.

FailOverClusters

/Peter