Cluster Disk Name and Size of the disk

Welcome Forums General PowerShell Q&A Cluster Disk Name and Size of the disk

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
2 months, 3 weeks ago.

  • Author
    Posts
  • #104563

    Participant
    Points: 0
    Rank: Member

    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 😉

  • #104567

    Participant
    Points: 0
    Rank: Member

    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 😉

  • #104569

    Participant
    Points: 1
    Rank: Member

    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

  • #109543

    Participant
    Points: 0
    Rank: Member

    Hello,

    Thx , for you'r replay.

    I had resolve my problem.

    As you say i check out the command of a cluster.

    the resolution was this part of the script :

     

    $Path = "C:\DeployNano\Csv"
    $Export =  Get-ClusterAvailableDisk | Export-Csv ("$Path\AvailableDisks.Csv") -Delimiter "," -Encoding UTF8
    $Disks = Import-Csv ("$Path\AvailableDisks.Csv")
    $length = $Disks.Count
    
    
    #Ajouts des disques disponibles
    Get-ClusterAvailableDisk | Add-ClusterDisk 
    
    $ExportCDcsv = Get-ClusterResource | Export-Csv ("$Path\ClusterDisks.csv") -Delimiter "," -Encoding UTF8
    $CDCsv = Import-Csv ("$Path\ClusterDisks.csv")
    $length = $CDCsv.Count
    $i = 0
    
    #Renommage des disques du cluster avant traitements des disques
    While ($i -le $length) {
      If ($CDCsv.name[$i] -eq "Disque de cluster 1") {
          $DiskName1 = $CDCsv.Name[$i]
          $BDNum = $i
          Write-Host "$DiskName1"
          (Get-ClusterResource $DiskName1).Name = "Disque du cluster 1"
      } 
      ElseIf ($CDCsv.Name[$i] -eq "Disque de cluster 2") {
          $DiskName2 = $CDCsv.Name[$i]
          $SDNum = $i
          Write-Host "$DiskName2"
          (Get-ClusterResource $DiskName2).Name = "Disque du cluster 2"
      }
      $i++
    }
    
    #Test taille disque le plus grand et le plus petit
    $i = 0
    $BDNum = 0
    $SDNum = 0
    While ($i -lt $Disks.Count) {
        If ($Disks.Size[$i] -ge $Disks.Size[$BDNUm]) {
            $BDNum = $i
            $BDNum
        }
        ElseIf ($Disks.Size[$i] -le   $Disks.Size[$SDNum]) {
            $SDNum = $i
            $SDNum
        }
        $i++
     }
    
    #Renommage des disques en fonction des disques trouvés
    $DName1 = $Disks.Name[$BDNum]
    $DName2 = $Disks.Name[$SDNum]
    (Get-ClusterResource $DName1).Name = "WebSite-Storage"
    (Get-ClusterResource $DName2).Name = "Quorum"
    
    #Declaration des variables pour la configuration du Quorum
    $ExportCDcsv = Get-ClusterResource | Export-Csv ("$Path\ClusterDisks2.csv") -Delimiter "," -Encoding UTF8
    $CDCsv = Import-Csv ("$Path\ClusterDisks2.csv")
    $i = 0
    $length = $CDCsv.count
    
    #Ajout du stockage present en CSV
    Get-ClusterResource "WebSite-Storage" | Add-ClusterSharedVolume -WarningAction Ignore
    
    #Configuration du Quorum
    Set-ClusterQuorum -DiskWitness Quorum
    

    Now i would like to rename the ClusterNeworkInterface, have you some idea to help me ?
    The same process doesn't work with the Network...

    I've try this script, but don't work :

     

    $Getcsv = Get-ClusterNetworkInterface | Export-Csv "$Path\ClusterNetworkInterface.csv" -Delimiter "," -Encoding UTF8
    $NetCsv = Import-Csv "$Path\ClusterNetworkInterface.csv"
    $i = 0
    $length = $NetCsv.count
    
    #Test noms interface & renommage
     While ($i -lt $length) {
       If ($NetCsv.Name[$i] -like "*TinCi*")  
       {
           Write-Host $NetCsv[$i].Network
           Get-ClusterNetworkInterface -Network $NetCsv[$i].Name | %{$_.Network = "TinCi"}
       }
       ElseIf ($NetCsv.Name[$i] -like "*iSCSI*")  
       {
           Write-Host $NetCsv[$i].Network
           Get-ClusterNetworkInterface -Network $NetCsv[$i].Name | %{$_.Network = "iSCSI"}
       }
       ElseIf ($NetCsv.Name[$i] -like "*HeartBeat*")  
       {
           Write-Host $NetCsv[$i].Network
           Get-ClusterNetworkInterface -Network $NetCsv[$i].Name | %{$_.Network = "HeartBeat"}
       }
       $i++
     }
    

    Message d'erreur :

    Réseau du cluster 1
    Get-ClusterNetworkInterface : Impossible de récupérer le réseau « HyperV1 - Tinci » du cluster « CFO ».
        Une erreur s'est produite lors de l'ouverture du réseau « HyperV1 - Tinci ».
        Les données fournies ont un type erroné
    Au caractère Ligne:11 : 8
    +        Get-ClusterNetworkInterface -Network $csv[$i].Name | %{$_.Name ...
    +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Get-ClusterNetworkInterface], ClusterCmdletException
        + FullyQualifiedErrorId : Get-ClusterNetworkInterface,Microsoft.FailoverClusters.PowerShell.GetNetworkInterfaceCommand
    Réseau du cluster 1
    Get-ClusterNetworkInterface : Impossible de récupérer le réseau « HyperV2 - Tinci » du cluster « CFO ».
        Une erreur s'est produite lors de l'ouverture du réseau « HyperV2 - Tinci ».
        Les données fournies ont un type erroné
    Au caractère Ligne:11 : 8
    +        Get-ClusterNetworkInterface -Network $csv[$i].Name | %{$_.Name ...
    +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Get-ClusterNetworkInterface], ClusterCmdletException
        + FullyQualifiedErrorId : Get-ClusterNetworkInterface,Microsoft.FailoverClusters.PowerShell.GetNetworkInterfaceCommand

    Thx for Replay 😉

  • #109567

    Participant
    Points: 0
    Rank: Member

    I'have try with this command :

    $Path = "C:\DeployNano\Csv"
    $Getcsv = Get-ClusterNetworkInterface | Export-Csv "$Path\ClusterNetworkInterface.csv" -Delimiter "," -Encoding UTF8
    $NetCsv = Import-Csv "$Path\ClusterNetworkInterface.csv"
    Get-ClusterNetworkInterface -Name $NetCsv.Name[0] | %{$_.Network = "Tinci"}
    

    I 'have the error message :

    « Network » est une propriété en lecture seule.
    Au caractère Ligne:1 : 55
    + ... usterNetworkInterface -Name $NetCsv.Name[0] | %{$_.Network = "Tinci"}
    +                                                     ~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation : (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyAssignmentException
    

    We can't change the name of this item ?

    Sry i haven't think there is some variable in my code.

You must be logged in to reply to this topic.