1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

適用済みWindowsUpdateのKB一覧を調べる

Last updated at Posted at 2019-06-01

2019/06/03追記

Where-Object$_を使わない表記についてコメントを頂けたので反映しました。
これに伴い記事末尾に余談も追記しました。


今日調べる機会があったので。PowerShellGet-HotFixコマンドレットで取得できます。

Get-HotFix | Where-Object HotFixID -match "KB4[01]"                                     # KB40 か KB01 が含まれる更新の一覧を取得する
Get-HotFix | Where-Object HotFixID -match "KB4[01]" | Sort-Object -Property InstalledOn # 適用日でソート 

なおGet-HotFix自体に-Idパラメータがありますが、ワイルドカードが使えないためあまり利便性は無いです。

PS C:\Users\me> Get-Help Get-HotFix -Parameter Id

-Id <String[]>
    指定された修正プログラム ID を持つ修正プログラムのみを取得します。既定値は、コンピューター上のすべての修正プログラムです。

    必須                         false
    位置                         1
    既定値                       All hotfixes
    パイプライン入力を許可する   false
    ワイルドカード文字を許可する false  # ← ココ

PS C:\Users\me>

なのでID検索したいときはWhere-Objectに渡して-match-likeで探す方が便利ですね。

また-ComputerNameパラメータが使えるため、(設定されていれば)リモートノードの情報を一括で取得することができます。

PS C:\Users\me> Get-HotFix -ComputerName REMOTE1,REMOTE2 | Where-Object HotFixID -match "KB289"

Source         Description      HotFixID      InstalledBy          InstalledOn
------         -----------      --------      -----------          -----------
REMOTE1        Security Update  KB2894856     REMOTE1\Administrator 2015/01/26 0:00:00
REMOTE1        Update           KB2896496     REMOTE1\Administrator 2015/01/26 0:00:00
REMOTE2        Security Update  KB2894856     REMOTE2\Administrator 2015/01/26 0:00:00
REMOTE2        Update           KB2896496     REMOTE2\Administrator 2015/01/26 0:00:00


PS C:\Users\me>

余談:Where-Object$_について

The $_ automatic variable represents each object that is passed to the Where-Object cmdlet.
The first command uses the script block format, the second command uses the comparison statement format.
The commands are equivalent and can be used interchangeably.

Get-Service | Where-Object {$_.Status -eq "Stopped"}
Get-Service | where Status -eq "Stopped"

Where-Objectをスクリプトブロックを用いずに使用する場合$_は不要とのことでした。
どこで刷り込まれた知識だったか、常に必要だと思っていました…。勉強になりました。
引用で示されている通り、$_を使う場合と使わない場合でコマンドは等価であり、互換性があるとのことです。

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?