WMI Call to retrieve Physical Serial Number on HDD's

1

I'm trying to write a script that incorporates a retrieved Drive Serial Number for a report. So far I've just been trying to get a WMI call or really anything to even retrieve it in the first place

WMIC PATH CIM_PhysicalMedia

works on some computers but not in the WinPE environment I need it to work on. I keep getting: Invalid XML Content.

Every command I try, I use both CIM_PhysicalMedia and Win32_PhysicalMedia and neither work when it doesn't work.

What's funny is, the system it works on is Windows 7 Pro but it doesn't work on another PC with the same OS! Am I missing a dll or something?

Please help! Again this is supposed to work in a WinPE environment. I do not know the version but I do know that WMIC works normally.

Please help!!

PS I have experience with simple WMI calls like wmic bios get serialnumber and the like but I have never messed with anything this apparently complex.

CanisDiBellum

Posted 2016-04-12T23:48:17.807

Reputation: 11

Have you Tried wmic diskdrive get serialnumber – NetworkKingPin – 2016-04-22T09:37:36.747

Answers

1

Am I missing a dll or something?

WMIC PATH CIM_PhysicalMedia

I keep getting: Invalid XML Content.

You could be missing a hotfix:

This issue occurs because the XML parser treats the control characters that are included in the serial number of some drives as invalid.

Try installing the hotfix available from the source link below ("Hotfix Download Available" button)


"Invalid XML content" error message when you run a WMIC command in Windows 7 or in Windows Server 2008 R2

SYMPTOMS

Consider the following scenario. You connect a USB flash drive to a computer that is running Windows 7 or Windows Server 2008 R2. You try to run one of the following Windows Management Instrumentation Command-line (WMIC) tool commands to query the hard disk drives on the computer:

wmic diskdrive get *
wmic diskdrive get serialNumber

In this scenario, you receive an error message that resembles the following:

Invalid XML content

CAUSE

This issue occurs because the XML parser treats the control characters that are included in the serial number of some drives as invalid. Therefore, the XML parser cannot parse content that includes these control characters. This behavior causes valid results for other drives to be displayed incorrectly, together with the behavior that is mentioned in the "Symptoms" section.

RESOLUTION

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing the problem described in this article. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Source "Invalid XML content" error message when you run a WMIC command in Windows 7 or in Windows Server 2008 R2

DavidPostill

Posted 2016-04-12T23:48:17.807

Reputation: 118 938