Script to Pull Disk Configuration

This is can be used to determine Disk Type Whether Dynamic or Basic, Volume information and Size of the disk.


strComputer = "."
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
WScript.Echo
WScript.Echo "=================================="
WScript.Echo "   DISKMANAGER Configuration "
WScript.Echo "=================================="
WScript.Echo

Set colDisk = objWMIService.ExecQuery("SELECT * FROM Win32_DiskPartition",,48)

For Each objItem In colDisk
 Select Case Ucase(objItem.Type)    
  Case "LOGICAL DISK MANAGER" : Disktype = "Dynamic Device ID : " & objItem.DiskIndex   
  Case Else : Disktype = "Basic Device ID : " & objItem.DiskIndex   
 End Select  
WScript.Echo "Disk Type: " & Disktype
Next
Wscript.Echo
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk")
For Each objItem In colItems
 if(objItem.DriveType <> 5 AND objItem.DriveType <> 2) then
  if(objItem.VolumeName <> "") then
   WScript.Echo "VolumeName : " & objItem.VolumeName
   WScript.Echo "Total Size : " & ROUND((objItem.Size)/(1024*1024*1024)) & " GB"
  else
   WScript.Echo "VolumeName : Local Disk"
   WScript.Echo "Total Size : " & ROUND((objItem.Size)/(1024*1024*1024)) & " GB"
  end if
 end if
Next

No comments:

Post a Comment