Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get-WindowsUpdateLog stream re-direction

Tags:

powershell

Has anyone noticed how the Get-WindowsUpdateLog cmdlet cannot be redirected to any streams?

Furthermore, storing the output into a variable, piping it, or any type of re-direction leads to the cmdlet to only be executed.

Any help redirecting/silencing the output of this command would be appreciated.

What I've tried:

Get-WindowsUpdateLog | Out-Null

Get-WindowsUpdateLog > $null

$sink = Get-WindowsUpdateLog
like image 397
Vish Avatar asked May 17 '26 01:05

Vish


1 Answers

Everything I could find failed to suppress the output of the CmdLet Get-WindowsUpdateLog. As you say, the displayed information in the console is not properly following the output streams as we know them in PowerShell.

The only workaround I found is using Jobs:

$Job = Start-Job -ScriptBlock {Get-WindowsUpdateLog}
$Job | Wait-Job | Remove-Job

This way all output is handled within the job and we don't retrieve the result. It's also unnecessary to retrieve it as the result is simply a text file placed in the -Path parameter.

like image 62
DarkLite1 Avatar answered May 28 '26 17:05

DarkLite1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!