Unable to retrieve physical size of available storage for cluster

后端 未结 2 1223
青春惊慌失措
青春惊慌失措 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.

    0 讨论(0)
  • 2021-01-25 05:50

    you can use wmi like this:

    Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" | Select DeviceID, FreeSpace
    

    throw in a computername parameter if you wish to do it remotely

    HTH, Matt

    PS. for a more readable report you can try this:

    Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" | 
      Select DeviceID, @{Name = "Free Space (%)" ; Expression= {[int] ($_.FreeSpace / $_.Size* 100)}},@{Name = "Free Space (GB)"; Expression = {[int]($_.Freespace / 1GB)}}, @{Name = "Size (GB)"; Expression = {[int]($_.Freespace / 1GB)}}
    
    0 讨论(0)
提交回复
热议问题