简体   繁体   中英

group all installed software in one cell by PowerShell

I have PowerShell script run on all PC on our network and get info from PC and save it in CSV file and update the file each time with new pc as a new row.

$logData = @(
                           [pscustomobject]@{
                            ComputerName = $ComputerName
                            IPAddress = $env:HostIP
                            User = $User
                            Email = $Email
                            ProgramsInstalled = $ProgramsInstalled
                            }
                           )
                     $logData | Export-Csv $csv -Encoding UTF8 -Append -NoTypeInformation -Force

I use this code to get all software installed on the pc

$ProgramsInstalled = (Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*') | Select-Object DisplayName

I did not get all software but when I run it alone and save it in a csv file I get the software each one of them in a row.

I want them grouped in one cell

You can use Get-Package if you like:

(Get-Package | Where-Object {$_.ProviderName -in @('Programs','msi','Chocolatey')} | Select-Object -ExpandProperty Name) -join ","

Here is the output like:

Microsoft DCF MUI (English) 2013,Microsoft OneNote MUI (English) 2013,Microsoft Office 32-bit Components 2013,Microsoft Office Shared 32-bit MUI (English) 2013,Microsoft Office OSM MUI (English) 2013,Microsoft Office OSM UX MUI (English) 2013,Microsoft InfoPath MUI (English) 2013,Microsoft Access MUI (English) 2013,Microsoft Office Shared Setup Metadata MUI (English) 2013,Microsoft Excel MUI (English) 2013,Microsoft Access Setup Metadata MUI (English) 2013,Microsoft PowerPoint MUI (English) 2013,Microsoft Publisher MUI (English) 2013,Microsoft Outlook MUI (English) 2013,Microsoft Groove MUI (English) 2013,Microsoft Word MUI (English) 2013,Microsoft Lync MUI (English) 2013,Microsoft Office Proofing (English) 2013,Microsoft Office Shared MUI (English) 2013,Microsoft Office Proofing Tools 2013 - English,Microsoft Office Proofing Tools 2013 - Español,Outils de vérification linguistique 2013 de Microsoft Office - Français,Microsoft Office Professional Plus 2013,Microsoft Office Professional Plus 2013,PowerShell 6-x86,Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.4148,TortoiseGit 2.10.0.2 (64 bit),Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022,Google Toolbar for Internet Explorer,Google Toolbar for Internet Explorer,PowerShell 7-x64,Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005,Google Drive,Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005,Intel(R) Management Engine Components,Intel(R) Management Engine Components,Thunderbolt(TM) Software,LibreOffice 6.4.5.2,Fast Boot,Fast Boot,GameCtrl B15.0803.1,GameCtrl B15.0803.1,Classic Shell,Python 3.4.0,SIV,SIV,AES Crypt,Oracle VM VirtualBox 5.2.6,EasyTune,EasyTune,Microsoft Visual C++ 2019 X86 Additional Runtime - 14.25.28508,paint.net,@BIOS B15.0630.1,@BIOS B15.0630.1,APP Center,APP Center,Adobe Reader XI (11.0.02),EZSetup B15.0623.1,EZSetup B15.0623.1,PuTTY release 0.73,Cloud Station Server,Cloud Station Server,Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161,BlueStacks Notification Center,ON_OFF Charge 2 B14.0217.1,ON_OFF Charge 2 B14.0217.1,Splashtop Streamer,Splashtop Streamer,PowerToys (Preview),Google Update Helper,Smart TimeLock B15.0626.1,Smart TimeLock B15.0626.1,VMware Player,Microsoft Visual C++ 2005 Redistributable,Intel(R) ME UninstallLegacy,BUSB,Intel(R) Rapid Storage Technology,Intel(R) Rapid Storage Technology,Microsoft Visual C++ 2019 X86 Minimum Runtime - 14.25.28508,Splashtop Remote Client,Splashtop Remote Client,Intel(R) Chipset Device Software,ConEmu 200615.x64,Microsoft Robocopy GUI,WinHide,OpenOffice.org 3.2,Metasploit-framework v5.0.94,Windows Driver Package - Realtek Semiconductor Corp. Net  (06/30/2014 1026.12.0606.2014),ShareX,AutoHotkey 1.1.32.00,CCleaner,EaseUS Data Recovery Wizard,Greenshot 1.2.10.6,IrfanView 4.54 (64-bit),Listary version 5.00,LockHunter 3.3, 32/64 bit,Mozilla Firefox 79.0 (x64 en-US),Mozilla Maintenance Service,Recuva,Sandboxie 5.22 (64-bit),Speccy,VLC media player,WinRAR 5.91 (64-bit),Bat To Exe Converter version 2.3.1,Microsoft Visual Studio Installer,Remo Recover 5.0,Quick Access Popup v10.5.1,Microsoft OneDrive,010 Editor 10.0.2 (32-bit),7-Zip 19.00,Adobe Flash Player 32 NPAPI,AnyBurn,Audacity 2.4.1,Auto-Patcher for Windows 98se June 2007 sp2,Avro Keyboard 4.5.1,Batchrun,BlueStacks App Player,Breevy 3.37,Cain & Abel 4.9.56,Dev-C++,EaseUS Partition Master 14.0,Everything 1.4.1.969 (x86),FileZilla Server,Git version 2.25.0,OpenGL Extensions Viewer 6.1,Google Chrome,HandBrake 1.3.3,Hidden Start,ImgBurn,Inno Setup version 6.0.5,JDownloader 2,Magical Jelly Bean KeyFinder,KGB Archiver 1.2.1.24,K-Lite Mega Codec Pack 4.0.0,LastPass (uninstall only),Microsoft Edge,Microsoft Edge Update,Mozilla Thunderbird 78.1.1 (x86 en-US),Nmap 7.80,Notepad++ (32-bit x86),Npcap,Orbit Downloader,qBittorrent 4.2.5,Resource Hacker Version 5.1.7,Revo Uninstaller 1.95,Smart Backup,Supercopier 1.2.3.2,Tweak UI,USB Virus Scan 2.4,WiFi Password Revealer,Winamp,WinCDEmu,WinPcap 4.1.3,WinSCP 5.17.6,WinThruster v6.9.1,Wireshark 3.2.4 32-bit,SHAREit,Yahoo! Messenger,UAS&TURBO DRIVER CONTROL TOOL 1.0.0.13,My Program 2 version 1.5,Qualcomm Atheros SmartNet Controller,Platform4 Player,Test version 1.5,Platform4 Player ActiveX Control,Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.25.28508,WhatPulse version 2.8.4,My Program version 1.5,LanOptimizer,Smart Recovery 2 B15.0626.1  (x64),Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.21005,Intel(R) Processor Graphics,Realtek High Definition Audio Driver,My Program 3 version 1.5

Or without -join ","

Microsoft DCF MUI (English) 2013
Microsoft OneNote MUI (English) 2013
Microsoft Office 32-bit Components 2013
Microsoft Office Shared 32-bit MUI (English) 2013
Microsoft Office OSM MUI (English) 2013
Microsoft Office OSM UX MUI (English) 2013
Microsoft InfoPath MUI (English) 2013
Microsoft Access MUI (English) 2013
Microsoft Office Shared Setup Metadata MUI (English) 2013
Microsoft Excel MUI (English) 2013
Microsoft Access Setup Metadata MUI (English) 2013
Microsoft PowerPoint MUI (English) 2013
Microsoft Publisher MUI (English) 2013
Microsoft Outlook MUI (English) 2013
Microsoft Groove MUI (English) 2013
Microsoft Word MUI (English) 2013
Microsoft Lync MUI (English) 2013
Microsoft Office Proofing (English) 2013
Microsoft Office Shared MUI (English) 2013
Microsoft Office Proofing Tools 2013 - English
Microsoft Office Proofing Tools 2013 - Español
Outils de vérification linguistique 2013 de Microsoft Office - Français
Microsoft Office Professional Plus 2013
Microsoft Office Professional Plus 2013
PowerShell 6-x86
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.4148
TortoiseGit 2.10.0.2 (64 bit)
Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022
Google Toolbar for Internet Explorer
Google Toolbar for Internet Explorer
PowerShell 7-x64
Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005
Google Drive
Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005
Intel(R) Management Engine Components
Intel(R) Management Engine Components
Thunderbolt(TM) Software
LibreOffice 6.4.5.2
Fast Boot
Fast Boot
GameCtrl B15.0803.1
GameCtrl B15.0803.1
Classic Shell
Python 3.4.0
SIV
SIV
AES Crypt
Oracle VM VirtualBox 5.2.6
EasyTune
EasyTune
Microsoft Visual C++ 2019 X86 Additional Runtime - 14.25.28508
paint.net
@BIOS B15.0630.1
@BIOS B15.0630.1
APP Center
APP Center
Adobe Reader XI (11.0.02)
EZSetup B15.0623.1
EZSetup B15.0623.1
PuTTY release 0.73
Cloud Station Server
Cloud Station Server
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161
BlueStacks Notification Center
ON_OFF Charge 2 B14.0217.1
ON_OFF Charge 2 B14.0217.1
Splashtop Streamer
Splashtop Streamer
PowerToys (Preview)
Google Update Helper
Smart TimeLock B15.0626.1
Smart TimeLock B15.0626.1
VMware Player
Microsoft Visual C++ 2005 Redistributable
Intel(R) ME UninstallLegacy
BUSB
Intel(R) Rapid Storage Technology
Intel(R) Rapid Storage Technology
Microsoft Visual C++ 2019 X86 Minimum Runtime - 14.25.28508
Splashtop Remote Client
Splashtop Remote Client
Intel(R) Chipset Device Software
ConEmu 200615.x64
Microsoft Robocopy GUI
WinHide
OpenOffice.org 3.2
Metasploit-framework v5.0.94
Windows Driver Package - Realtek Semiconductor Corp. Net  (06/30/2014 1026.12.0606.2014)
ShareX
AutoHotkey 1.1.32.00
CCleaner
EaseUS Data Recovery Wizard
Greenshot 1.2.10.6
IrfanView 4.54 (64-bit)
Listary version 5.00
LockHunter 3.3, 32/64 bit
Mozilla Firefox 79.0 (x64 en-US)
Mozilla Maintenance Service
Recuva
Sandboxie 5.22 (64-bit)
Speccy
VLC media player
WinRAR 5.91 (64-bit)
Bat To Exe Converter version 2.3.1
Microsoft Visual Studio Installer
Remo Recover 5.0
Quick Access Popup v10.5.1
Microsoft OneDrive
010 Editor 10.0.2 (32-bit)
7-Zip 19.00
Adobe Flash Player 32 NPAPI
AnyBurn
Audacity 2.4.1
Auto-Patcher for Windows 98se June 2007 sp2
Avro Keyboard 4.5.1
Batchrun
BlueStacks App Player
Breevy 3.37
Cain & Abel 4.9.56
Dev-C++
EaseUS Partition Master 14.0
Everything 1.4.1.969 (x86)
FileZilla Server
Git version 2.25.0
OpenGL Extensions Viewer 6.1
Google Chrome
HandBrake 1.3.3
Hidden Start
ImgBurn
Inno Setup version 6.0.5
JDownloader 2
Magical Jelly Bean KeyFinder
KGB Archiver 1.2.1.24
K-Lite Mega Codec Pack 4.0.0
LastPass (uninstall only)
Microsoft Edge
Microsoft Edge Update
Mozilla Thunderbird 78.1.1 (x86 en-US)
Nmap 7.80
Notepad++ (32-bit x86)
Npcap
Orbit Downloader
qBittorrent 4.2.5
Resource Hacker Version 5.1.7
Revo Uninstaller 1.95
Smart Backup
Supercopier 1.2.3.2
Tweak UI
USB Virus Scan 2.4
WiFi Password Revealer
Winamp
WinCDEmu
WinPcap 4.1.3
WinSCP 5.17.6
WinThruster v6.9.1
Wireshark 3.2.4 32-bit
SHAREit
Yahoo! Messenger
UAS&TURBO DRIVER CONTROL TOOL 1.0.0.13
My Program 2 version 1.5
Qualcomm Atheros SmartNet Controller
Platform4 Player
Test version 1.5
Platform4 Player ActiveX Control
Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.25.28508
WhatPulse version 2.8.4
My Program version 1.5
LanOptimizer
Smart Recovery 2 B15.0626.1  (x64)
Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.21005
Intel(R) Processor Graphics
Realtek High Definition Audio Driver
My Program 3 version 1.5

This...

(Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*') | Select-Object DisplayName

...brings back an array.

If you want this in a single column, then you have to join the array results.

$ProgramsInstalled = Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
                                            'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | 
Select-Object -Property DisplayName
# Results
<#
DisplayName                                                                  
-----------                                                                  
                                                                             
SAPIEN Document Explorer 2020                                                
GIMP 2.10.14                                                                 
Git version 2.24.0.2                                                         
...
#>


$ProgramsInstalled = ((Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
                                              'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | 
Select-Object -Property DisplayName)).DisplayName -join ','
# Results
<#
SAPIEN Document Explorer 2020,GIMP 2.10.14,Git version 2.24.0.2,...
#>

Refer to Getting List of Installed Applications that Matches Add/Remove Programs List

You can give a try for something like that :

$OS_Architecture = $env:PROCESSOR_ARCHITECTURE
if($OS_Architecture -eq 'x86') 
{
    $key = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
}
else
{
    $key = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
}

(Get-ItemProperty $Key).DisplayName -Join ','

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM