インストールされているプログラムの一覧を取得するには、WMIのWin32_Productを使用します。
一覧を取得
PS C:\work> Get-WmiObject -Class Win32_Product -ComputerName .
IdentifyingNumber : {B5473F47-EEA5-44AE-8213-78E5908CDCE6}
Name : Microsoft Visual Studio 2017 Tools for Unity
Vendor : Microsoft Corporation
Version : 3.1.0.0
Caption : Microsoft Visual Studio 2017 Tools for Unity
IdentifyingNumber : {BC25B808-A11C-4C9F-9C0A-6682E47AAB83}
Name : Gtk# for .Net 2.12.26
Vendor : Xamarin, Inc.
Version : 2.12.26
Caption : Gtk# for .Net 2.12.26
IdentifyingNumber : {F99F24BF-0B90-463E-9658-3FD2EFC3C992}
Name : Microsoft Identity Extensions
Vendor : Microsoft Corporation
Version : 2.0.1459.0
Caption : Microsoft Identity Extensions
-以下略-
全てのプロパティを表示
Propertyパラメーターに(*)を指定することですべてのプロパティを表示できます。
PS C:\work> Get-WmiObject -Class Win32_Product -ComputerName . | Where-Object -FilterScript {$_.Name -eq "SQL Server 2016 Management Studio"} | Format-List -Property *
PSComputerName : USERPC
Name : SQL Server 2016 Management Studio
Version : 13.0.15700.28
InstallState : 5
__GENUS : 2
__CLASS : Win32_Product
__SUPERCLASS : CIM_Product
__DYNASTY : CIM_Product
__RELPATH : Win32_Product.IdentifyingNumber="{0D000000-F000-4000-8006-70000F000009}",Name="SQL Server 2016 Management Studio",Version="13.0.15700.28"
__PROPERTY_COUNT : 27
__DERIVATION : {CIM_Product}
__SERVER : USERPC
__NAMESPACE : root\cimv2
-以下略-
横一列に表示
Select-Objectを使ってプロパティを横一列に表示します。
PS C:\work> Get-WmiObject -Class Win32_Product -ComputerName . | Select-Object Name, Vendor, Version, Caption
Name Vendor Version Caption
---- ------ ------- -------
Microsoft Visual Studio 2017 Tools for Unity Microsoft Corporation 3.1.0.0 Microsoft Visual Studio 2017 Tools for Unity
Microsoft Identity Extensions Microsoft Corporation 2.0.1459.0 Microsoft Identity Extensions
Microsoft Application Error Reporting Microsoft Corporation 12.0.6015.5000 Microsoft Application Error Reporting
Microsoft DCF MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft DCF MUI (Japanese) 2013
Microsoft OneNote MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft OneNote MUI (Japanese) 2013
Microsoft Office OSM MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft Office OSM MUI (Japanese) 2013
Microsoft Office OSM UX MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft Office OSM UX MUI (Japanese) 2013
Microsoft InfoPath MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft InfoPath MUI (Japanese) 2013
Microsoft Access MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft Access MUI (Japanese) 2013
Microsoft Excel MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft Excel MUI (Japanese) 2013
Microsoft PowerPoint MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft PowerPoint MUI (Japanese) 2013
Microsoft Publisher MUI (Japanese) 2013 Microsoft Corporation 15.0.4569.1506 Microsoft Publisher MUI (Japanese) 2013
-以下略-
CSVファイルに出力
PS C:\work> Get-WmiObject -Class Win32_Product -ComputerName . | Select-Object Name, Vendor, Version, Caption | Export-Csv programlist.csv -Encoding Default