WMI Вызов для получения физического серийного номера на жестких дисках

1339
CanisDiBellum

Я пытаюсь написать сценарий, который содержит полученный серийный номер диска для отчета. До сих пор я просто пытался получить WMI-вызов или вообще что-нибудь, чтобы вообще получить его.

WMIC PATH CIM_PhysicalMedia 

работает на некоторых компьютерах, но не в среде WinPE, на которой он мне нужен. Я продолжаю получать:Invalid XML Content.

Каждая команда, которую я стараюсь, я использую как CIM_PhysicalMediaи Win32_PhysicalMediaи ни работать, когда он не работает.

Что забавно, система, на которой он работает, - это Windows 7 Pro, но она не работает на другом ПК с той же ОС! Я скучаю по DLL или что-то?

Пожалуйста помоги! Опять же, это должно работать в среде WinPE. Я не знаю версию, но я знаю, что WMIC работает нормально.

Пожалуйста помоги!!

PS У меня есть опыт работы с простыми вызовами типа WMI wmic bios get serialnumberи т.п., но я никогда не сталкивался с чем-то настолько сложным.

1
Пробовал ли ты `wmic diskdrive получить серийный номер` NetworkKingPin 7 лет назад 0

1 ответ на вопрос

1
DavidPostill

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