Is there any Faster method to do WMI query from Powershell ..?
<p>Wrote a small script to find the number Multipaths from the windows servers using WMI query. It works well for the servers which can connect directly without any issue. But if one server is pingable but not able to reach through WMI script, it takes long time to return the error ( for example if a linux server hostname is present in the servers.txt list).. Can somebody help me to do the same in a faster way..?</p>

<pre><code>$Servers = Get-Content .\Servers.txt

$ErrorActionPreference = ‘SilentlyContinue’

FOREACH ($Server in $Servers) {

Write-Host $Server -nonewline

if (test-connection -computername $Server -Count 1 -quiet) {

$Name = $null
$NoPath =$null
$MPIODisks =$null

$MPIODisks = Get-WmiObject -Namespace root\wmi -Class mpio_disk_info -ComputerName "$Server" |Select-Object "DriveInfo"

    if ($MPIODisks -eq $Null) {

    write-host "`t - Unable to connect" -fore "RED"

    } else {    

        write-host ""
        write-host "Drive Name `tNo.Path" -fore "yellow"

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

                    foreach ($Drive in $mpiodrives) {
                $Name = $Drive.Name
                $NoPath = $Drive.Numberpaths

                    If ($NoPath -lt 4) {
                    Write-Host $Name `t -nonewline
                    write-host $NoPath -fore "Red"
                    } else {
                    Write-Host $Name `t -nonewline
                    write-host $NoPath -fore "Green"
                    }
                    }
            }

    }

    write-host ""

} else {

write-host "`t- Unknown Host" -fore "Red"
write-host ""
}
</code></pre>

<p>}</p>