Bela
Bela

Reputation: 61

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:

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

Upvotes: 6

Views: 25120

Answers (2)

Ian King
Ian King

Reputation: 21

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

    }
}

Upvotes: 2

riro
riro

Reputation: 121

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 }

Upvotes: 1

Related Questions