私はWindowsがカウントを返すのと同じ方法で利用可能なWindowsアップデートの数を返すPowershellスクリプトを書くのに疲れています。私が抱えている問題は、Window Updateが返すカウントに一致するように自分のカウントを取得できないということです。
例えば私のスクリプトを返すことがあります。
クリティカル回数:0
重要数:1
オプションの数:30
しかし、Windows Updateがあると言うだろう:
クリティカル数:1
重要なカウント:1
任意の数:29
Windows Updateでカウントを表示するためにWindowsが使用する基準を知っている人はいますか?
更新カウントを表示するためにWindowsが使用する基準は何ですか?
# ----- Get All Assigned updates --------
$UpdateSession = New-Object -ComObject "Microsoft.Update.Session"
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
$SearchResult = $UpdateSearcher.Search('IsInstalled=0')
# ----- Matrix Results for type of updates that are needed --------
$critical = $SearchResult.updates | where { $_.MsrcSeverity -eq "Critical" }
$important = $SearchResult.updates | where { $_.MsrcSeverity -eq "Important" }
$optional = $SearchResult.updates | where { ($_.MsrcSeverity -ne "Critical") -and ($_.MsrcSeverity -ne "Important") }
マイケル - 私はあなたのコードをそのまま使用しましたが、私はクリティカル、重要、その他の理由でリターンを得ることができませんでした。検索基準と "$ _。MsrcSeverity -eq $ null"を使用してコードで使用しましたが、結果はWindowsが返したものと一致しませんでした。私のコード:C = 0、I = 0、O = 31 WindowsはC = 0、I = 1、O = 30を返します。私のコードとWindowsで異なると報告されている1つの更新プログラムはKB2600217という更新プログラムであり、重要なセクションでは表示されていますがチェックされていません。他のアイデア? – Eskimo
@エスキモー申し訳ありませんが、私はこのテーマについてたくさん知りません。参考になるリンクがいくつかあります。 http://blogs.technet.com/b/jamesone/archive/2009/01/27/managing-windows-update-with-powershell.aspx http://richardspowershellblog.wordpress.com/2011/06/12/windows-updates-4-tidy-up-get-update http://blogs.technet.com/b/heyscriptingguy/archive/2012/01/20/get-windows-update-status-information- by-using-powershell.aspx –