Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法在设备管理器中检测所有Prob设备,无论是在C#还是Powershell中_C#_Powershell - Fatal编程技术网

有没有办法在设备管理器中检测所有Prob设备,无论是在C#还是Powershell中

有没有办法在设备管理器中检测所有Prob设备,无论是在C#还是Powershell中,c#,powershell,C#,Powershell,是否有一种方法可以检测设备管理器中的所有问题设备,无论是在C#还是Powershell中,您都可以使用及其类来检索计算机上安装的设备及其状态。您的查询将包含以下内容: $computer = "LocalHost" $namespace = "root\CIMV2" Get-WmiObject -class Win32_PnPEntity -computername $computer -namespace $namespace 根据具体要求,您可以根据可用性、状态或ConfigManag

是否有一种方法可以检测设备管理器中的所有问题设备,无论是在C#还是Powershell中,您都可以使用及其类来检索计算机上安装的设备及其状态。您的查询将包含以下内容:

$computer = "LocalHost" 
$namespace = "root\CIMV2" 
Get-WmiObject -class Win32_PnPEntity -computername $computer -namespace $namespace

根据具体要求,您可以根据可用性、状态或ConfigManagerErrorCode字段进行筛选。如果不知道你的“问题”到底是什么,就不可能给你一个更详细的答案。

谢谢你,谢谢allot@David Brabant。实际上,我想要一个PowerShell脚本来检测设备管理器中的所有问题设备。所需输出格式:DeviceName BeforeStatusCode AfterStatusCode固定/非固定扬声器22 0Fixed@AB_Softbeforestatus代码似乎不可用。您可以通过管道将问题项传送到
Where{$\ configmanagerrorcode-gt 0}| FT Name、configmanagerrorcode、Status
,从而获取问题项,并显示任何错误代码。或者
其中{$\u.Status-ne“OK”-和![string]::IsNullOrEmpty($\u.Status)}
将为您提供一切不正常的信息(包括没有错误代码的降级)。