1
votes

I'm a relatively inexperienced coder and I've been running into an issue with getting the physical disk serial number remotely via a VBScript.

Currently I'm using the default script in Scriptomatic V2, by the Scripting Guys. I'm running it from a 2003 Server and trying to get info from Win2000 and WinXP SP2/SP3 systems. I've seen from a couple tutorials that the WMI class recommended is Win32_PhysicalMedia.

Including the useful bits:

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("STN_XP","STN_2000")
  For Each strComputer In arrComputers
    WScript.Echo
    WScript.Echo "=========================================="
    WScript.Echo "Computer: " & strComputer
    WScript.Echo "=========================================="

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMedia", "WQL", _
                                      wbemFlagReturnImmediately + wbemFlagForwardOnly)

    For Each objItem In colItems
      '(Removed a couple from the code, just showing the useful ones)
      WScript.Echo "Model: " & objItem.Model
      WScript.Echo "Name: " & objItem.Name
      WScript.Echo "SerialNumber: " & objItem.SerialNumber
      WScript.Echo "Tag: " & objItem.Tag
      WScript.Echo
      Next
    Next

Now the output I get is below: Note this is the exact output from running the script with all calls; no data is returned beyond the objItem.Tag value:

==========================================
Computer: STN_XP
==========================================
Capacity:
Caption:
CleanerMedia:
CreationClassName:
Description:
HotSwappable:
Manufacturer:
MediaDescription:
MediaType:
Model:
Name:
OtherIdentifyingInfo:
PartNumber:
PoweredOn:
Removable:
Replaceable:
SerialNumber:
SKU:
Status:
Tag: \\.\PHYSICALDRIVE0
Version:
WriteProtectOn:

==========================================
Computer: STN_2000
==========================================

All computers are connected to a domain, I'm logged in to the primary admin account. Using some of the other WMI libraries, I get data, and on one specific computer so far I've received a serial number (and tag, but nothing else). I've read up on this being an issue for Vista, where you are required to run in admin mode. This shouldn't be an issue here, due to the OSes in use. Anyone know what might be wrong?

As a follow-up question, does anyone know how to get the Serial Number from a 2000 station?

Thanks in advance for any help you can give me.

1
So, what's the question? - Cody Gray
Question is how can I get the serial number for a hard drive remotely. objItem.SerialNumber should work, but doesn't. Is there something that needs to be done by me to access to it, or is there another way around that I can take? - Insomnia
Ah, sorry. I just realized what you meant. There is no data being returned. The output that I see is exactly as shown, no data beyond the Tag: is being returned properly. Edited the OP to clarify. - Insomnia

1 Answers

0
votes

Comment out the On Error Resume Next with a single quote, and post the error message that is likely being returned.