PSWindows從 Powershell 腳本執行 Get-WUList 時更新空白輸出

PSWindows從 Powershell 腳本執行 Get-WUList 時更新空白輸出

我使用 PSWindowsUpdate 模組來更新工作場所的大多數機器。但是,當透過 Powershell 腳本執行 Get-WUList(或 Get-WUInstall)命令時,我得到空白,如附圖所示。我真的很希望能夠看到將要安裝/正在安裝哪些更新。PSWindowsUpdate 空白輸出

每當我手動運行命令時,一切都會按預期顯示。我嘗試過使用 write-host 命令,但最終得到了一堆無法真正解讀的文字。任何人都知道如何在透過腳本而不是手動執行時獲取 Get-WUList/Get-WUInstall 的輸出?

*我應該注意,我使用遠端桌面管理器 (RDM) 遠端存取我的系統。他們有一個稱為遠端桌面代理的功能,允許透過 RDM 介面同時在多台電腦上執行腳本。

編輯包括腳本

Echo "Enabling Windows Update Services"
Get-Service wuauserv | Set-Service -StartupType Manual
Get-Service bits | Set-Service -StartupType Manual

Echo "Enabling updates for additional Microsoft components and software"
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false

Echo "Querying Microsoft Update Server for Windows Updates"
Get-WUList -MicrosoftUpdate | Select Title, KB, Status

Echo "Hiding Unnecessary Updates"
Hide-WUUpdate -Title "*Visio*"    -Confirm:$false
Hide-WUUpdate -Title "*OneDrive*" -Confirm:$false
Hide-WUUpdate -Title "*OneNote*"  -Confirm:$false
Hide-WUUpdate -Title "*Outlook*"  -Confirm:$false
Hide-WUUpdate -Title "*Skype*"    -Confirm:$false

Echo "Downloading and Installing Windows Updates"
Get-WUInstall -MicrosoftUpdate -AcceptAll -IgnoreReboot | Select Title, KB

Echo "Stopping Windows Update Services"
Get-Service wuauserv | Stop-Service -PassThru | Set-Service -StartupType Disabled
Get-Service bits | Stop-Service -PassThru | Set-Service -StartupType Disabled

相關內容