WUSA.exe Pass Errors to Powershell

This topic contains 2 replies, has 3 voices, and was last updated by  Alex Aymonier 1 week, 6 days ago.

  • Author
    Posts
  • #83518

    Joseph Monarch
    Participant

    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
  • #83545

    Olaf Soyk
    Participant

    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"

  • #83762

    Alex Aymonier
    Participant

    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"

You must be logged in to reply to this topic.