端末にインストールされているアプリ情報を取得するスクリプトです。
レジストリから「プログラムの追加と削除」に相当するものを引っ張って来ています。
目次
目次 |
---|
実際のコード |
コードの解説 |
実際のコード↑
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)で出力します。 |
↓ のページでこの情報を元に端末毎に差分を出す方法も記載しました。
参考にしたサイト