0

I am trying to write a script that will search our computers for certain windows updates and if it finds the update then it uninstalls the update on the computer. Currently it is not restarting. I am using an update on the VM that I know is installed to test. It is quiet but it will not reboot. Any idea what I am doing wrong or what I should change?

if ((
gwmi -cl win32_reliabilityRecords `
-filter "sourcename = 'Microsoft-Windows-WindowsUpdateClient'" | `
where { $_.message -match 'KB2912208' } | `
select -expand message)) `
{
'wusa.exe /uninstall /kb:2912208 /quiet /forcerestart'
}
Iwifia
  • 23
  • 2
  • 7
  • Does it restart if you run `wusa.exe /uninstall /kb:2912208 /quiet /forcerestart` manually? – aphoria May 06 '14 at 19:06
  • Seems to do nothing, just sits and hangs. – Iwifia May 06 '14 at 19:21
  • Why not use the `restart-computer` cmdlet after the uninstall? – Jason Morgan May 06 '14 at 19:21
  • Due to it being silent I have no idea if it completes the uninstall. That would be a great solution normally though. – Iwifia May 06 '14 at 19:22
  • The docs for `/quiet` say `- Quiet mode, no user interaction. Reboot as needed.` Maybe a reboot is not necessary for this update? – aphoria May 06 '14 at 19:26
  • That was my first thought but after reboot the update still shows. Also the /forcereboot was added so regardless we reboot the computer. – Iwifia May 06 '14 at 19:31
  • What if you run the uninstaller without `/quiet`? Does it uninstall then? – aphoria May 06 '14 at 19:38
  • Says update cannot be found for any updates... ummm wtf... – Iwifia May 06 '14 at 20:52
  • you can check the exit code of `wusa.exe` and if successful, use `restart-computer` otherwise, log the error code. – djs May 06 '14 at 21:57
  • well the error itself im finding is that it does not recognize a single update that I am putting into it, even though they are installed. – Iwifia May 06 '14 at 21:58

0 Answers0