-1

I have huge list of servers and workstations where I need to review patches for a specific date range. I have my command working, but there is one machine that apparently has a WMI issue, and its throwing an error, effectively aborting the entire operation. I attempted to add some command to ignore the error and keep going but nothing seems to catch and continue, it always aborts and I never see the output.

Get-HotFix -ComputerName (Get-Content .\TARGETS.txt) |  Where { $_.InstalledOn -gt '7/29/2017' -AND $_.InstalledOn -lt '8/25/2017' } | sort InstalledOn

I've tried adding $erroractionpreference = 'SilentlyContinue' but that just doesn't throw the error to the screen, the hotfix list still doesn't get displayed.

z-vap
  • 56
  • 8
  • Try adding this to the catch block so you can at least see the error: `Try { Get-HotFix ... -ErrorAction Stop } Catch { Write-Host "[$($_.Exception.GetType().FullName)] $($_.Exception.Message)" }` – Maximilian Burszley Aug 25 '17 at 15:21

1 Answers1

0

You may need to trace down the process tree.

Get-Hotfix uses the Win32_QuickFixEngineering WMI class. You can usually find out provider information in PS help files or you can use wbemtest.

Once you know that information, you can check the Windows Event Viewer > View >Show Analytic and Debug logs option. Navigate to Microsoft > Windows > WMI Activity, and right click Operational log then select Enable Log from the pane on the right. Then right click the Trace log, and similarly enable.

The next time you try and run the command (or maybe in a new PS session, not sure) there should be more detailed information to help you determine the root problem.

MS Scripting Guy Ed Wilson details the process with a how-to here as well:

https://blogs.technet.microsoft.com/heyscriptingguy/2012/09/12/use-powershell-to-troubleshoot-provider-load-failure/

trebleCode
  • 1,751
  • 15
  • 27