WUSA.exe Pass Errors to Powershell


I have been successful at getting wusa.exe to run and create its’ own error log. How can I get it to pass any errors to Powershell so they can be written into the scripts logfile?

wusa $item /quiet /norestart | Out-Null
"$(Get-TimeStamp) | SUCCESS | Installed $item" | Out-File -FilePath $logpath -Append -Encoding ASCII



wusa /?
you can get the possible command line arguments wusa is able to process. I would assume they didn’t design it to pass errors to the shell in another way than writing a log file. But because you can specify the log file wusa should use you could get the content of that log file and include it in whatever you like. :wink:

BTW: In your example you actually throw away everything wusa could possibly output with “| Out-Null

Check out the The FREE 2017 #PSBlogWeek eBook here http://www.adamtheautomator.com/free-2017-psblogweek-ebook/

Looks like its got a chapter on exactly what your looking for. “Logging and Error Handling Best Practices for Automating Windows Update Installs”