Windows Update をする際に、更新プログラムを手動で検出したいという場面はよくあると思います。Windows Server 2012 R2 以前では、こういった場合に wuauclt /detectnow というおなじみのコマンドを実行していましたが、Windows Server 2016 では、この detectnow オプションが廃止されています。
同じことをするには、以下のような手段をとることができます。
代替手段 1 (PowerShell)
PowerShell で wuauclt /detectnow と同じ効果を得るには、次のようにします。
1 |
(New-Object -ComObject "Microsoft.Update.AutoUpdate").DetectNow() |
代替手段 2 (VBScript)
VBScript を利用しても、wuauclt /detectnow と同じことができます。
1 2 |
Set automaticUpdates = CreateObject("Microsoft.Update.AutoUpdate") automaticUpdates.DetectNow() |