How to determine storage type (SAN/NAS/local disk) remotely, using PowerShell?

Bela picture Bela · Jan 25, 2013 · Viewed 23.2k times · Source

I have to collect the attached storage types of each server in our environment: Several hundreds of W2K3/W2K8 servers.

A script would be very useful to determine if the attached storage is SAN / SAN mirrored / NAS / local or combination of these. The problem is that I haven't really found any good solution.

I was thinking about a script, and the best I could figure out would do something like the following:

  • If the server uses SAN, Veritas Storage Foundation is always installed, so I would search for it with gwmi win32_product. This is really slow, and this doesn't provide the information if the storage is SAN, or SAN mirrored.
  • If the attached storage is NAS, there must be an ISCSI target ip, and I would search for that somehow.

I really don't think these methods are acceptable though. Could you please help me find a better way to determine the attached storage types somehow?

Thank you very much

Answer

Ian King picture Ian King · Sep 12, 2013

I found an article about accessing the VDS service in powershell. Getting More Information About You Cluster LUN’s

Massaged the code a bit to get type. Works even on 2003.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Storage.Vds") | Out-Null
$oVdsServiceLoader = New-Object Microsoft.Storage.Vds.ServiceLoader
$oVdsService = $oVdsServiceLoader.LoadService($null) 
$oVdsService.WaitForServiceReady() 
$oVdsService.Reenumerate() 
$cDisks = ($oVdsService.Providers |% {$_.Packs}) |% {$_.Disks}
$cPacks = $oVdsService.Providers |% {$_.Packs}

foreach($oPack in $cPacks)
{
    If($oPack.Status -eq "Online")
    {
        foreach($oDisk in $oPack.Disks)
        {
            Write-Host "$($oDisk.FriendlyName) ( $($oDisk.BusType) )"
        }


        foreach($oVolume in $oPack.Volumes)
        {
            Write-Host "`t$($oVolume.AccessPaths) ( $($oVolume.Label) )"
        }

    }
}