Powershell Scan for PDQi - Device Manager Errors
So I am running a PDQi PowerShell scan as follows...
Issue I am having is the PDQi tables for the scanner don't update once the error has been resolved and a subsequent scan is performed.
If I run the script manually in a PS window on the PC, I no longer get the error as long as the device manager issues have been resolved. I can toggle disabling a device in device manager and rerun the script in a local PS window on the PC to show data again etc. etc...
$ProblemDevices = Get-WmiObject Win32_PNPEntity |
Where-Object{$_.ConfigManagerErrorCode -ne 0} |
Select Name, DeviceID, ConfigManagerErrorCode, Manufacturer
ForEach($ProblemDevice in $ProblemDevices){
$ErrorDesc = Switch ($ProblemDevice.ConfigManagerErrorCode){
1 {"Device is not configured correctly."}
2 {"Windows cannot load the driver for this device."}
3 {"Driver for this device might be corrupted, or the system may be low on memory or other resources."}
4 {"Device is not working properly. One of its drivers or the registry might be corrupted."}
....
}
$ProblemDevice | ForEach-Object {
[PSCustomObject]@{
"Problem Device" = $_.Name
"Manufacturer" = $_.Manufacturer
"Device ID" = $_.DeviceID
"Error Code" = $_.ConfigManagerErrorCode
"Error Description" = $ErrorDesc
}
}
}
0
Comments
The PowerShell Scanner has a bug where it will show the previous results if the script returns nothing. To work around this, you have to return an object and set the value of each property to $null. Here's an example: https://github.com/pdq/PowerShell-Scanners/blob/master/PowerShell%20Scanners/Get%20Available%20Windows%20Updates/Get%20Available%20Windows%20Updates.ps1
Please send an email to support@pdq.com to let them know you encountered this bug.
Please sign in to leave a comment.