Author Posts

November 2, 2017 at 7:51 pm

All,

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

November 3, 2017 at 1:22 am

Joseph,

with

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. 😉

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

November 7, 2017 at 9:50 pm

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"