Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 456
Bela Avatar asked Jan 25 '13 10:01

Bela


2 Answers

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) )"
        }

    }
}
like image 120
Ian King Avatar answered Sep 29 '22 18:09

Ian King


You could probably find the info in one of the following WMI classes:

Win32_LogicalDisk http://msdn.microsoft.com/en-us/library/windows/desktop/aa394173(v=vs.85).aspx

Win32_Volume http://msdn.microsoft.com/en-us/library/windows/desktop/aa394515(v=vs.85).aspx

Win32_DiskDrive http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132(v=vs.85).aspx

Then... do something like:

Get-AdComputer Server* | Foreach-Object { Get-WmiObject -Class Win32_DiskDrive -ComputerName $_.Name }
like image 45
riro Avatar answered Sep 29 '22 17:09

riro