?
Solved

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

Posted on 2011-10-31
7
Medium Priority
?
611 Views
Last Modified: 2012-06-27
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
Comment
Question by:MBSSG
  • 4
  • 3
7 Comments
 
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 37060426
 
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
 

Author Comment

by:MBSSG
ID: 37060772
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
 
LVL 84

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 37060847
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:MBSSG
ID: 37060866
AWESOME! So will this list all the drives on the machine? and how can I output it to a text file?
0
 
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 37060875
yes it will output all the drives.. cscript file.vbs > output.txt
0
 

Author Comment

by:MBSSG
ID: 37060884
Great! Thanks so much for the help. I really appreciate it.
0
 

Author Closing Comment

by:MBSSG
ID: 37060886
Great simple little VB Script
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question