4

I have WSUS installed on a Server 2012R2 box. I am trying to use the Get-WsusComputer powershell command to get a list of computers with pending or failed updates. The documentation for the command seems to suggest that -ComputerUpdateStatus is the correct option for this.

-ComputerUpdateStatus Specifies the computer update state as represented in the WSUS Console user interface. The acceptable values for this parameter are: ...

The problem I am having is that using this option doesn't seem to make any difference. When I look at the console in the GUI about 75% of my systems are in the OK state, a few have been offline for a while, a few have failures, and the rest show a couple 1-2 updates in the needed column.

PS D:\> get-wsuscomputer -ComputerTargetGroups Workstations | Measure-Object

Count    : 264

PS D:\> get-wsuscomputer -ComputerTargetGroups Workstations `
>>                  -ComputerUpdateStatus Failed  | Measure-Object

Count    : 264

PS D:\> get-wsuscomputer -ComputerTargetGroups Workstations `
>>                  -ComputerUpdateStatus FailedOrNeeded | Measure-Object

Count    : 264

Is this option simply broken? Or am I missing something obvious about how to use it?

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • 1
    What happens if you pipe it to a where object filtered by the same property? – Colyn1337 Oct 29 '15 at 19:07
  • Have a look also at this post http://blogs.technet.com/b/heyscriptingguy/archive/2012/01/19/use-powershell-to-find-missing-updates-on-wsus-client-computers.aspx – kekimian Oct 29 '15 at 19:37
  • @Colyn1337 as far as I can tell there are no properties about the needed/failed/installed updates that are returned from the command. – Zoredache Oct 29 '15 at 19:37
  • @kekimian not sure what I am supposed to be looking at on that page. It seems to be about adding help to a command? Did you paste the correct link? – Zoredache Oct 29 '15 at 19:39
  • @zoredache wrong link sorry, I have updated the link – kekimian Oct 29 '15 at 19:41
  • @kekimian I have seen that article, and I will probably go with the method described it. It just seems needlessly complex. I believe it also also predates the inclusion of the WSUS powershell commands. So I was hoping the `get-wsuscomputer` would be all I need. – Zoredache Oct 29 '15 at 19:46
  • @zoredache did you tried to pipe get-wsuscomputer to where-object as Colyn1337 suggested? – kekimian Oct 29 '15 at 19:51
  • @kekimian Like I said above there doesn't appear to be any property in the returned object as seen by `get-wsuscomputer | Get-Member` that I would be able to use in a where-object. – Zoredache Oct 29 '15 at 20:24
  • I note that combining some parameters produces differing results. I don't have access to pursue further until later. `Get-WsusComputer -ComputerUpdateStatus -IncludedInstallationStates ` – jscott Oct 29 '15 at 21:00
  • 1
    See also: https://connect.microsoft.com/PowerShell/feedback/details/1157299/get-wsuscomputer-computerupdatestatus-doesnt-work – jscott Oct 30 '15 at 14:55

2 Answers2

3

There is a bug in the WSUS PowerShell Module. I decompiled Module and the GetWSUSComputer command looks like somebody defaulted a variable to all statuses if null even though the variable hadn't had a value defined until the next line. The design of the module doesn't expose the Computer Update status in the object Get-WSUSComputer exposes so you can't filter it after the fact either.

1

Here is the article describing everything you are interested in.

https://blogs.technet.microsoft.com/heyscriptingguy/2012/01/20/get-windows-update-status-information-by-using-powershell/

I have tried out some of the code from this article, it works pretty well. Please note that there is a typo at:

$wsus.GetUpdateStatue($updatescope,$False)

it should be:

$wsus.GetUpdateStatus($updatescope,$False)
  • Right, like I said, when somebody posted in the comments this method seems to work. But I am frustrated that the Powershell Commandlets that seem claim they have the functionality, don't work. Not saying your answer isn't useful for getting the job done. It just isn't as easy of a job, since you have to use .NET stuff instead of pure powershell. – Zoredache Aug 25 '16 at 16:41
  • I completely agree with you. This should be powershell out-of-the-box feature – Stefan Mihajlovic Aug 25 '16 at 18:15