xml - "XML is invalid"当 Get-CimInstance 与 -ComputerName 一起提供时

标签 xml powershell

我在谷歌上搜索了一段时间,但似乎找不到正确的答案。

我的笔记本电脑是 AD 域的一部分。我用它来探索/开发 PowerShell 和 WMI 中的工具。我注意到,每当我使用 -ComputerName 在 Win32_ComputerSystem 类上获取 CimInstance 时,我都会收到 XML 无效 错误:

PS C:\Users\jsung> Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName jsung03-pc
Get-CimInstance : The WS-Management service cannot process the request because the XML is invalid.
At line:1 char:1
+ Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName jsung03-pc
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ParserError: (root\cimv2:Win32_ComputerSystem:String) [Get-CimInstance], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338043,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
+ PSComputerName        : jsung03-pc

jsung03-pc 是我笔记本电脑的主机名。如果我取出 -ComputerName 参数,查询将返回一个没有任何问题的结果。

同样的症状出现在我的笔记本电脑和台式机上。两者都运行 Windows 7 SP1。我加载了 RSAT 4.0 和 .NET 4.5.2。 WinRM 和 WsMAN 通过 Enable-PSRemoting 启用。

PS C:\Users\jsung> $PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

PS C:\Users\jsung> Get-Service wi*
Status   Name               DisplayName
------   ----               -----------
Stopped  WinDefend          Windows Defender
Running  WinHttpAutoProx... WinHTTP Web Proxy Auto-Discovery Se...
Running  Winmgmt            Windows Management Instrumentation
Running  WinRM              Windows Remote Management (WS-Manag...

如果我删除 -ComputerName jsung03-pc,cmdlet 将返回一个没有错误的结果:

PS C:\Users\jsung> Get-CimInstance -ClassName Win32_ComputerSystem
Name             PrimaryOwnerName         Domain                   TotalPhysicalMemory      Model                   Manufacturer
----             ----------------         ------                   -------------------      -----                   ------------
JSUNG03-PC       ntapadmin           <domain.com>            4147822592               4384BE6                 LENOVO

查询“Win32_Process”类时未显示此问题。

Test-WSMan显示系统运行的是3.0

PS C:\Users\jsung> Test-WSMan -ComputerName jsung03-pc -Authentication Default
wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 6.1.7601 SP: 1.0 Stack: 3.0

我运行了 WMI 诊断实用程序并尝试通过 cscript WMIDiag.vbs WriteInRepository=Root 恢复存储库,但仍然没有成功。几乎没有关于 XML 无效 的信息。

谁能阐明什么数据库可能已损坏以及如何解决这个问题?

最佳答案

您是否尝试过用引号将 ComputerName 括起来?当计算机名称带有连字符时,我见过这样奇怪的事情发生。

关于xml - "XML is invalid"当 Get-CimInstance 与 -ComputerName 一起提供时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26474632/

相关文章:

xml - 当我要格式化 namenode 时,我收到错误提示 org.xml.sax.SAXParseException

java - 如何修复 Jaxb 的 xmlMapper "Multiple fields representing property "PS""问题?

powershell - 为什么这个 powershell 或过滤器不起作用?

windows - 将 .MOD 视频文件转换为 .mp4 但保持原始文件日期

python - 防止 BeautifulSoup 将我的 XML 标签转换为小写

html - Magento,如何在 block 中添加静态 url 链接

PowerShell - 从程序调用中剥离 .exe

powershell - 是否可以同时打印文件字符串,文件哈希和上次修改日期?

powershell - Import-StartLayout 对当前用户没有任何作用

c# - Xml 命名空间前缀规范器