1
2

More than 1 year has passed since last update.

PowerShellでアプリ情報を取得する

Last updated at Posted at 2022-03-24

端末にインストールされているアプリ情報を取得するスクリプトです。
レジストリから「プログラムの追加と削除」に相当するものを引っ張って来ています。

目次

目次
実際のコード
コードの解説

実際のコード

get_app.ps1
Get-ChildItem -Path(
'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstal') |
% { Get-ItemProperty $_.PsPath | Select-Object DisplayName, DisplayVersion, Publisher } |
Export-Csv -NoTypeInformation -Encoding Default get_app.csv

コードの解説

コード 意味
Get-ChildItem -Path ( ) ()内のアイテムを取得します。
'HKLM:SOFTWARE\Microsoft
\Windows\CurrentVersion\Uninstall',
「プログラムの追加と削除」のアプリ一覧(コンピューター配下)
'HKCU:SOFTWARE\Microsoft
\Windows\CurrentVersion\Uninstall',
「プログラムの追加と削除」のアプリ一覧(カレントユーザー配下)
'HKLM:SOFTWARE\WOW6432Node\Microsoft
\Windows\CurrentVersion\Uninstal'
「プログラムの追加と削除」のアプリ一覧(コンピューター配下かつ32bit版)
% { } { } の中を要素の数だけ繰り返し処理します
Get-ItemProperty $_.PsPath | 取得したアイテム「レジストリパス」を元に、さらに詳細な情報を取得し、パイプの右側に渡します。
Select-Object DisplayName, DisplayVersion, Publisher 渡された詳細な情報から、アプリ名・バージョン・製作元のみ抽出します。
Export-Csv -NoTypeInformation -Encoding Default get_app.csv 抽出した結果を「get_app.csv」にデフォルトのエンコード(大体utf-8)で出力します。

↓ のページでこの情報を元に端末毎に差分を出す方法も記載しました。


参考にしたサイト
1
2
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
2