我使用下面提到的VBScript从多个服务器收集MPIO磁盘活动路径信息。我试图将VBScript转换为PowerShell模块,但无法找到适当的类或按预期获得值。
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命令,但无法获得路径信息:
$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
}
}它提供的产出如下:
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 :发布于 2016-05-27 23:13:00
(Get-WmiObject -Namespace root\wmi -Class mpio_disk_info).driveinfo |
foreach-object {
"Name: $($_.name) Paths: $($_.numberpaths)"
}https://stackoverflow.com/questions/33980139
复制相似问题