Use WMI and Powershell to check and see if disk is Virtual, local or SAN

PS N:\> Get-WmiObject Win32_DiskDrive | % {
>>   $disk = $_
>>   $partitions = “ASSOCIATORS OF ” +
>>                 “{Win32_DiskDrive.DeviceID=’$($disk.DeviceID)’} ” +
>>                 “WHERE AssocClass = Win32_DiskDriveToDiskPartition”
>>   Get-WmiObject -Query $partitions | % {
>>     $partition = $_
>>     $drives = “ASSOCIATORS OF ” +
>>               “{Win32_DiskPartition.DeviceID=’$($partition.DeviceID)’} ” +
>>               “WHERE AssocClass = Win32_LogicalDiskToPartition”
>>     Get-WmiObject -Query $drives | % {
>>       New-Object -Type PSCustomObject -Property @{
>>         Disk        = $disk.DeviceID
>>         DiskSize    = $disk.Size
>>         DiskModel   = $disk.Model
>>         Partition   = $partition.Name
>>         RawSize     = $partition.Size
>>         DriveLetter = $_.DeviceID
>>         VolumeName  = $_.VolumeName
>>         Size        = $_.Size
>>         FreeSpace   = $_.FreeSpace
>>       }
>>     }
>>   }
>> }
>>

results

DiskSize    : 53694627840
RawSize     : 53560279040
FreeSpace   : 52996517888
Disk        : \\.\PHYSICALDRIVE7
DriveLetter : E:
DiskModel   : NETAPP LUN C-Mode  Multi-Path Disk Device
VolumeName  : Sys DB
Size        : 53560274944
Partition   : Disk #7, Partition #0

DiskSize    : 53686402560
RawSize     : 53552742400
FreeSpace   : 48738844672
Disk        : \\.\PHYSICALDRIVE1
DriveLetter : D:
DiskModel   : VMware Virtual disk SCSI Disk Device
VolumeName  : Bin
Size        : 53552738304
Partition   : Disk #1, Partition #0

via the Internet

vbscript based computer inventory scripts

strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _     & “{impersonationLevel=impersonate}!\\” _     & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _     (“Select * from Win32_OperatingSystem”) For Each objOperatingSystem in colOperatingSystems     Wscript.Echo objOperatingSystem.Caption & _     ”  ” & objOperatingSystem.Version Next

strComputer = “.” Set objWMIService = GetObject( _     “winmgmts:\\” & strComputer & “\root\cimv2”) Set IPConfigSet = objWMIService.ExecQuery _     (“Select IPAddress from Win32_NetworkAdapterConfiguration” _         & ” where IPEnabled=TRUE”)   For Each IPConfig in IPConfigSet     If Not IsNull(IPConfig.IPAddress) Then         For i=LBound(IPConfig.IPAddress) _         to UBound(IPConfig.IPAddress)             WScript.Echo IPConfig.IPAddress(i)         Next     End If Next

various WMI computer inventory commands via Powershell

wmi Win32_OperatingSystem.CSName
gwmi Win32_OperatingSystem.Name

Get-WmiObject Win32_OperatingSystem).Name | format-list

(Get-WmiObject Win32_OperatingSystem).CSName

Get-WmiObject Win32_OperatingSystem | Format-List csname, name

Get-WmiObject Win32_NetworkAdapterConfiguration | Format-List IPAddress

Get-WmiObject Win32_OperatingSystem | Format-List csname, name

gwmi Win32_NetworkAdapterConfiguration |     Where { $_.IPAddress } | # filter the objects where an address actually exists     Select -Expand IPAddress | # retrieve only the property *value*     Where { $_ -like ‘192.168.*’ }