首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MPIO磁盘活动路径

MPIO磁盘活动路径
EN

Stack Overflow用户
提问于 2015-11-29 06:38:11
回答 1查看 6.5K关注 0票数 1

我使用下面提到的VBScript从多个服务器收集MPIO磁盘活动路径信息。我试图将VBScript转换为PowerShell模块,但无法找到适当的类或按预期获得值。

代码语言:javascript
复制
Dim oFSO, oTSIn, oTSOut
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTSOut = oFSO.CreateTextFile("results.txt")
Set oTSIn = oFSO.OpenTextFile("servers.txt")

Do Until oTSIn.AtEndOfStream
    sServerName = oTSIn.ReadLine
    intFreeSpace6=sServerName
    oTSOut.WriteLine intFreeSpace6

    On Error Resume Next
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20

    Dim wmi
    Set wmi = GetObject("winmgmts://" + sServerName + "/root/WMI")

    Dim mpio_disks
    Set mpio_disks = wmi.ExecQuery("SELECT * FROM MPIO_DISK_INFO")

    For Each disk In mpio_disks
        Dim mpio_drives
        mpio_drives = disk.DriveInfo

        For Each drive In mpio_drives
            Dim name
            name = drive.Name

            Dim paths
            paths = drive.NumberPaths

            Dim space
            space="= "

            oTSOut.WriteLine name & space & paths

            'WScript.Echo  name & paths 
        Next
    Next
Loop

oTSIn.Close
oTSOut.Close
MsgBox "Finished!"

以下是尝试的PowerShell命令,但无法获得路径信息:

代码语言:javascript
复制
$MPIODisks = Get-WmiObject -Namespace "root\wmi" -Class mpio_disk_info -ComputerName "$Server" |
             Select-Object "DriveInfo"

Write-Host "Host Name : " $Server

foreach ($Disk in $MPIODisks) {
    $mpiodrives = $disk.DriveInfo

    foreach ($Drive in $mpiodrives) {
        Write-Host "Drive : " $Drive.Name
        Write-Host "Path : " $Drive.Numberpath
    }
}

它提供的产出如下:

代码语言:javascript
复制
Drive :  MPIO Disk0
Path :
Drive :  MPIO Disk1
Path :
Drive :  MPIO Disk2
Path :
Drive :  MPIO Disk3
Path :
Drive :  MPIO Disk4
Path :
Drive :  MPIO Disk6
Path :
Drive :  MPIO Disk7
Path :
Drive :  MPIO Disk8
Path :
Drive :  MPIO Disk10
Path :
EN

回答 1

Stack Overflow用户

发布于 2016-05-27 23:13:00

代码语言:javascript
复制
(Get-WmiObject -Namespace root\wmi -Class mpio_disk_info).driveinfo | 
    foreach-object {
        "Name: $($_.name) Paths: $($_.numberpaths)"
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33980139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档