Unable to retrieve physical size of available storage for cluster

后端 未结 2 1259
青春惊慌失措
青春惊慌失措 2021-01-25 04:51

I am half way down with my work and now stuck.

I am trying to fetch information about available storage devices for a cluster. I am able to fetch the list of available s

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-25 05:41

    You can get this information from WMI, but it takes a couple steps:

    $resources = Get-WmiObject -namespace root\MSCluster MSCluster_Resource -filter "Type='Physical Disk'"
    $resources | foreach {
        $res = $_
        $disks = $res.GetRelated("MSCluster_Disk")
        $disks | foreach {
            $_.GetRelated("MSCluster_DiskPartition") |
                select @{N="Name"; E={$res.Name}}, @{N="Status"; E={$res.State}}, Path, VolumeLabel, TotalSize, FreeSpace 
        }
    } | ft
    

    That will give you output like the following:

    Name                  Status Path  VolumeLabel  TotalSize  FreeSpace
    ----                  ------ ----  -----------  ---------  ---------
    Cluster Disk 2             2 K:    New Volume        5220       5163
    SQL - FAS3070 SiteB        2 S:    MC_SQL            5597       5455
    SM Test                    2 M:    SM Test           1024        992
    DTC - FAS3070B             2 F:    MC_WITNESS        5346       5289
    Cluster Disk Witness       2 E:    New Volume        5322       5267
    Cluster Disk 1             2 G:    MC_DTC            5088       5035
    Cluster Disk 3             2 T:    SQL               5119       4999
    

    If you don't care about the resource name/status you can skip those steps and jump straight to the partition (and it'll run much quicker):

    gwmi -namespace root\MSCluster MSCluster_DiskPartition | ft Path, VolumeLabel, TotalSize, FreeSpace
    

    Edit: Note that the size is in MB and a Status of "2" means that the disk is online.

提交回复
热议问题