How can I use Invoke-Wuinstall silently

2019-08-03 19:58发布

问题:

$WUInstallScript = { Import-Module C:\Path\PSWindowsUpdate.psm1; Get-WUInstall -AcceptAll -AutoReboot}
Invoke-WUInstall -ComputerName $hostname -Script $WUInstallScript

I am running this command but Invoke-WUInstall pops up that whether I want to confirm this action. I want to invoke this silently. Is there any option to do this?

回答1:

Add -Confirm:$false switch like this:

Invoke-WUInstall -ComputerName $hostname -Script $WUInstallScript -Confirm:$false


回答2:

I use a wu.ps1 file containing:

Import-Module PSWindowsUpdate
Invoke-Command  {Get-WUInstall -AcceptAll -AutoReboot -Confirm:$FALSE}

and then something like:

powershell -file "C:\usr\wu.ps1"