PowershellでWindowsUpdateを実施する方法
doc
系統1:MuraAtVwnet * フルオートでWindows Updateする * Windows Updateを自動で再起動とアップデートを繰り返すバッチファイルを作る
系統2: * Windows Update PowerShell Module * 【Management】Windows Update Powershell Module (1) * PowerShellによるWindowsUpdateの自動化 * PowerShellでWindows Updateを自動化した * WindowsUpdateをPowershellで制御してみた
方針
系統2の方法で実施する。
基本的には「Install-WindowsUpdate -AcceptAll」コマンドを毎日決まった時間に実行するだけでよいはず。
PowershellでWindows Updateを行う手順
- 管理者権限でPowershellを開く
- 「PSWindowsUpdate」モジュールのインストール ※ 初回のみ
Install-Module -Name PSWindowsUpdate - 「Get-WindowsUpdate」コマンドで更新するモジュールを取得する
ComputerName Status KB Size Title
------------ ------ -- ---- -----
PC-Name ------- KB5014329 349MB 2022-05 .NET 5.0.17 Security Update for x64 Client (KB5014329)
PC-Name ------- KB5014330 435MB 2022-05 .NET 6.0.5 Security Update for x64 Client (KB5014330)
※ Updateがない場合は何も表示されない 1. 「Install-WindowsUpdate -AcceptAll」コマンドでモジュールのダウンロード&インストール 「Install-WindowsUpdate -AcceptAll -AutoReboot」とすると自動で再起動がかかる
Confirm
Are you sure you want to perform this action?
Performing the operation "(xxxx/xx/xx xx:xx:xx) 2022-05 .NET 5.0.17 Security Update for x64 Client (KB5014329)[349MB]"
on target "PC-Name ".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a
X ComputerName Result KB Size Title
- ------------ ------ -- ---- -----
1 PC-Name Accepted KB5014329 349MB 2022-05 .NET 5.0.17 Security Update for x64 Client (KB5014329)
1 PC-Name Accepted KB5014330 435MB 2022-05 .NET 6.0.5 Security Update for x64 Client (KB5014330)
Reboot is required. Do it now? [Y / N] (default is 'N')
自動で毎日定時でWindows Updateを行う手順
手順
- PowerShellスクリプトを作成
- タスクスケジューラで実行設定