1

假设我有一些集群磁盘,我可以从 cmdlet get-clusterresource 中取出它们。

PS N:\> get-clusterresource | ?{$_.resourcetype.name -eq "Physical Disk"}

Name             State        Group             ResourceType
----             -----        -----             ------------
Cluster Disk 1   Online       Cluster Group     Physical Disk
Cluster Disk 2   Online       SQLServer         Physical Disk
Cluster Disk 3   Online       SQLServer         Physical Disk
Cluster Disk 4   Online       SQLServer         Physical Disk
Cluster Disk 5   Online       SQLServer         Physical Disk
Cluster Disk 6   Online       WINCLUSTER        Physical Disk
Cluster Disk 7   Online       SQLServer         Physical Disk
Cluster Disk 8   Online       SQLServer         Physical Disk
Cluster Disk 9   Online       SQLServer         Physical Disk

我怎样才能得到相应的驱动器号?这些磁盘可能不在同一个节点上。

我尝试使用 get-clusterparameter cmdlet,但它不包含此信息。

谢谢。

4

1 回答 1

3

一些快速的谷歌搜索出现了这篇文章,可以这样采用:

Get-ClusterResource | ? { $_.ResourceType.Name -eq "Physical Disk" } | % {
  $resourceName = $_.Name

  $resource  = gwmi MSCluster_Resource -Namespace root/mscluster |
               ? { $_.Name -eq $resourceName }
  $disk      = gwmi -Namespace root/mscluster -Query `
               "ASSOCIATORS OF {$resource} WHERE ResultClass=MSCluster_Disk"
  $partition = gwmi -Namespace root/mscluster -Query `
               "ASSOCIATORS OF {$disk} WHERE ResultClass=MSCluster_DiskPartition"

  $partition | select Path
}

或者您可以在这样的管道中执行此操作:

$diskqry = 'ASSOCIATORS OF {{{0}}} WHERE ResultClass=MSCluster_Disk'
$partqry = 'ASSOCIATORS OF {{{0}}} WHERE ResultClass=MSCluster_DiskPartition'

Get-ClusterResource | ? { $_.ResourceType.Name -eq 'Physical Disk' } `
  | % { gwmi MSCluster_Resource -Namespace root/mscluster -Filter "Name='$_'" } `
  | % { gwmi -Namespace root/mscluster -Query ($diskqry -f $_) } `
  | % { gwmi -Namespace root/mscluster -Query ($partqry -f $_) } `
  | select Path
于 2013-07-30T18:26:50.047 回答