• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 632
  • Last Modified:

Script to query DISK ID for multiple disks on a windows server

Hi I was wondering if someone could help me write a script to query the disk ID and disk signature of a windows 2003 and windows 2008 server either remotely or locally run on the server and output it to a text file.
0
MBSSG
Asked:
MBSSG
  • 4
  • 3
1 Solution
 
David Johnson, CD, MVPOwnerCommented:
 
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_Volume",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_Volume instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Access: " & objItem.Access
    Wscript.Echo "DeviceID: " & objItem.DeviceID
    Wscript.Echo "DriveLetter: " & objItem.DriveLetter
Next

Open in new window

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_DiskDrive",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_DiskDrive instance"
    Wscript.Echo "-----------------------------------"
    If isNull(objItem.Capabilities) Then
        Wscript.Echo "Capabilities: "
    Else
        Wscript.Echo "Capabilities: " & Join(objItem.Capabilities, ",")
    End If
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DeviceID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    Wscript.Echo "SerialNumber: " & objItem.SerialNumber
    Wscript.Echo "Signature: " & objItem.Signature
    Wscript.Echo "StatusInfo: " & objItem.StatusInfo
    Wscript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    Wscript.Echo "SystemName: " & objItem.SystemName
Next

Open in new window

0
 
MBSSGAuthor Commented:
Hi thanks for the code. I am however looking for specifically the disk ID. I have attached the screenshot. Hopefully you can help.     DISK ID via Diskpart command
0
 
David Johnson, CD, MVPOwnerCommented:
Just had to convert Decimal to Hex
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_DiskDrive",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_DiskDrive instance"
    Wscript.Echo "-----------------------------------"
    If isNull(objItem.Capabilities) Then
        Wscript.Echo "Capabilities: "
    Else
        Wscript.Echo "Capabilities: " & Join(objItem.Capabilities, ",")
    End If
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DeviceID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    Wscript.Echo "SerialNumber: " & objItem.SerialNumber
    Wscript.Echo "Signature: " & HEX(objItem.Signature)
    Wscript.Echo "StatusInfo: " & objItem.StatusInfo
    Wscript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    Wscript.Echo "SystemName: " & objItem.SystemName
Next

Open in new window

0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
MBSSGAuthor Commented:
AWESOME! So will this list all the drives on the machine? and how can I output it to a text file?
0
 
David Johnson, CD, MVPOwnerCommented:
yes it will output all the drives.. cscript file.vbs > output.txt
0
 
MBSSGAuthor Commented:
Great! Thanks so much for the help. I really appreciate it.
0
 
MBSSGAuthor Commented:
Great simple little VB Script
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now