检索类型名称层次结构时发生以下异常:"未找到"

时间:2016-12-08 23:30:51

标签: powershell wmi

我正在努力保存网络共享设置。在尝试使用属性时,我似乎删除了一些内容。

以下是代码和错误:

new-object system.management.managementclass win32_trustee

new-object : The following exception occurred while retrieving the type name hierarchy: "Not found ".
At line:1 char:1
+ new-object system.management.managementclass win32_trustee
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-Object], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetTypeNameHierarchy,Microsoft.PowerShell.Commands.NewObjectCommand

Powershell如何使用WMI以及我在哪里可以检查该类是否已被删除?

编辑: 谢谢大家。我会在这里回复,因为我有更好的格式化工具。

@Mathias R. Jessen

gwmi win32_trustee
gwmi : Invalid class "win32_trustee"


[wmi]"win32_trustee"
Cannot convert value "win32_trustee" to type "System.Management.ManagementObject". Error: "Specified argument was out of the range of valid values."

Get-CimInstance win32_trustee
Get-CimInstance : Invalid class 

@JosefZ

Get-TypeData wmiclass
TypeName                     Members                                                           
--------                          -------                                                           
System.Management.ManagementClass {[Name, System.Management.Automation.Runspaces.AliasPropertyData]}


[wmiclass].Assembly.Location
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll


Get-Command *-type*
CommandType     Name                                               Version    Source                                              
-----------     ----                                               -------    ------                                              
Cmdlet          Add-Type                                           3.1.0.0    Microsoft.PowerShell.Utility                        
Cmdlet          Get-TypeData                                       3.1.0.0    Microsoft.PowerShell.Utility                        
Cmdlet          Remove-TypeData                                    3.1.0.0    Microsoft.PowerShell.Utility                        
Cmdlet          Update-TypeData                                    3.1.0.0    Microsoft.PowerShell.Utility 


new-object wmiclass win32_trustee
new-object : The following exception occurred while retrieving the type name hierarchy: "Not found ".

编辑: 该链接回答了这个问题: https://serverfault.com/questions/820267/problems-creating-win32-trustee-object/820482#820482

以下是答案: 您可以尝试重新编译MOF文件。 Win32_Trustee是位于%SystemRoot%\ System32 \ wbem \中的secrcw32.mof的一部分 打开提升的命令提示符并运行以下命令: mofcomp.exe%SystemRoot%\ System32 \ wbem \ secrcw32.mof 有关重新编译WMI MOF的更多信息,请访问:https://blogs.technet.microsoft.com/askperf/2009/04/13/wmi-recompiling-wmi-mofs/

0 个答案:

没有答案