rpr
rpr

Reputation: 121

MPIO Disk active path

I was using the below mentioned VBScript to collect the MPIO Disk active path information from multiple servers. I was trying to convert the VBScript to a PowerShell module, but am unable to find the appropriate class or get the values as expected.

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 command tried is below but not able to get the path information:

$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
    }
}

It is giving output as mentioned below:

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 :

Upvotes: 1

Views: 8540

Answers (1)

wonderer
wonderer

Reputation: 11

(Get-WmiObject -Namespace root\wmi -Class mpio_disk_info).driveinfo | 
    foreach-object {
        "Name: $($_.name) Paths: $($_.numberpaths)"
}

Upvotes: 0

Related Questions