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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s