通过PowerShell将所有已安装的软件分组到一个单元中

通过PowerShell将所有已安装的软件分组到一个单元中,powershell,csv,Powershell,Csv,我让PowerShell脚本在我们网络上的所有PC上运行,从PC上获取信息,并将其保存在CSV文件中,每次将新PC作为新行更新该文件 $logData = @( [pscustomobject]@{ ComputerName = $ComputerName IPAddress = $env:HostIP

我让PowerShell脚本在我们网络上的所有PC上运行,从PC上获取信息,并将其保存在CSV文件中,每次将新PC作为新行更新该文件

$logData = @(
                           [pscustomobject]@{
                            ComputerName = $ComputerName
                            IPAddress = $env:HostIP
                            User = $User
                            Email = $Email
                            ProgramsInstalled = $ProgramsInstalled
                            }
                           )
                     $logData | Export-Csv $csv -Encoding UTF8 -Append -NoTypeInformation -Force
我使用此代码在电脑上安装所有软件

$ProgramsInstalled = (Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*') | Select-Object DisplayName
我并没有得到所有的软件,但当我单独运行它并将其保存在csv文件中时,我得到了一行中的每个软件

我想把它们分组在一个单元格中

这个

(Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*') | Select-Object DisplayName
…带回一个数组

如果要将其放在单个列中,则必须将数组结果合并

$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,...
#>
$ProgramsInstalled=Get-ItemProperty-路径“HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*”,
“HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*”
选择对象-属性DisplayName
#结果
$PROGRAMSSINSTALLED=((获取项目属性-路径“HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*”,
“HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*”
选择对象-属性DisplayName()。DisplayName-连接','
#结果
请参阅

您可以尝试这样做:

$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 ','

如果愿意,您可以使用
Get Package

(Get-Package | Where-Object {$_.ProviderName -in @('Programs','msi','Chocolatey')} | Select-Object -ExpandProperty Name) -join ","
以下是如下输出:

Microsoft DCF MUI(英语)2013、Microsoft OneNote MUI(英语)2013、Microsoft Office 32位组件2013、Microsoft Office共享32位MUI(英语)2013、Microsoft Office OSM MUI(英语)2013、Microsoft Office OSM UX MUI(英语)2013、Microsoft InfoPath MUI(英语)2013、Microsoft Access MUI(英语)2013、,Microsoft Office共享安装元数据MUI(英语)2013、Microsoft Excel MUI(英语)2013、Microsoft Access安装元数据MUI(英语)2013、Microsoft PowerPoint MUI(英语)2013、Microsoft Publisher MUI(英语)2013、Microsoft Outlook MUI(英语)2013、Microsoft Groove MUI(英语)2013、Microsoft Word MUI(英语)2013、Microsoft Lync MUI(英语)2013,微软Office校对(英语)2013,微软Office共享MUI(英语)2013,微软Office打样工具2013 -英语,微软Office打样工具2013 - ESPA No.OL,Outles de VeRiTrimeValueStudio 2013 de微软办公楼-弗兰Sou-AIS,微软Office专业加2013,微软Office专业加2013,Plus S壳6x866,微软Visual C++2008可再分发-X64,90.307294148,TortoiseGit 20.0.2(64位),微软Visual C++ 2008可再分发-X64,0.0.21022,谷歌浏览器工具栏,Internet Explorer的谷歌工具栏,PortSeal7x64,微软Visual C++ 2013 x86最小运行时间-12 0.21005,谷歌驱动器,微软Visual C++ 2013 x86附加运行时间-120.21005,英特尔(R)管理引擎组件,英特尔(r)管理发动机部件,Thunderbolt(TM)软件,LyBeffice B4.0803.1,快速启动,GoCeCrl B150803.1,GoCeCrl B150803.1,经典外壳,Python 3.4.0,SIV,SIV,AES隐窝,Oracle VM VialalBox 5.2.6,EasyTune,EasyTobe,微软Visual C++ 2019 x86附加运行时间-1425.25508,Pr.net,@ BIOS BS150630.1,@ BIOS BS150630.1,APP中心,App Center,Adobe Reader席(110.02),EZStabl B150623.1,EZStVB150623.1,腻子发布0.73,云站服务器,云站服务器,微软Visual C++ 2008可再分发- X86 90.30727.6161,蓝宝石通知中心,OnOxOffice收费2 B1402171,OnOffOffice收费2 B1402171,Splashtop Streamer,Splashtop Streamer,PowerToys(预览)谷歌更新助手,智能TimeLoCK B150621.1,智能TimeLoCK B150622.1,VMware播放器,微软Visual C++ 2005可再分发,英特尔(R)ME卸载,BASB,英特尔(R)快速存储技术,英特尔(R)快速存储技术,微软Visual C++ 2019 x86最小运行时间-1425.25508,SpopHopTop-FieldClient,SpopHopTop-Exchange客户端,英特尔(R)芯片组设备软件,ConEmu 200615.x64,Microsoft Robocopy GUI,WinHide,OpenOffice.org 3.2,Metasploit framework v5.0.94,Windows驱动程序包-Realtek Semiconductor Corp.Net(06/30/2014 1026.12.0606.2014),ShareX,自动热键1.1.32.00,CCleaner,EaseUS数据恢复向导,Greenshot 1.2.10.6,iFanView 4.54(64位),Listary版本5.00,LockHunter 3.3,32/64位,Mozilla Firefox 79.0(美国x64),Mozilla维护服务,Recuva,Sandboxie 5.22(64位),Speccy,VLC媒体播放器,WinRAR 5.91(64位),Bat-To-Exe转换器版本2.3.1,Microsoft Visual Studio安装程序,远程恢复5.0,快速访问弹出v10.5.1,Microsoft OneDrive,010编辑器10.0.2(32位),7-Zip 19.00,Adobe Flash Player 32 NPAPI,AnyBurn,Audacity 2.4.1,Windows 98se自动修补程序2007年6月sp2,Avro键盘4.5.1,Batchrun,BlueStacks应用程序播放器,Breevy 3.37,Cain&Abel 4.9.56,Dev-C++,EaseUS分区主控14.0,Everything 1.4.1.969(x86),FileZilla服务器,Git版本2.25.0,OpenGL Extensions Viewer 6.1,Google Chrome,HandBrake 1.3.3,Hidden Start,ImgBurn,Inno安装版本6.0.5,JDownloader 2,Magazic Jelly Bean KeyFinder,KGB Archiver 1.2.1.24,K-Lite Mega编解码器包4.0.0,LastPass(仅限卸载),Microsoft Edge,Microsoft Edge更新,Mozilla Thunderbird 78.1.1.1(x86-en-US),Nmap 7.80,记事本++(32位x86),Npcap,Orbit Downloader,qBittorrent 4.2.5,Resource Hacker 5.1.7版,Revo卸载程序1.95,智能备份,Superciper 1.2.3.2,Tweak UI,USB病毒扫描2.4,WiFi密码展示器,Winamp,WindDemu,WinPcap 4.1.3,WinSCP 5.17.6,Win推力器v6.9.1,Wireshark 3.2.4 32位,SHAREit,Yahoo!Messenger,UAS&TURBO驱动程序控制工具1.0.0.13,我的程序2版1.5,高通ASPARS Smart Cutler控制器,Prime4播放器,测试版本1.5,Prime4播放器ActiveX控件,微软Visual C++ +2015-2019可重新分发(X86)-1425.25508,WASH脉冲版本2.84,我的程序版本1.5,LANOptivisher,智能恢复2 B150622.1(X64),微软Visual C++ 2013可再分发(X86)-120.21005,英特尔(R)处理器图形,Realtek高清音频驱动程序,My Program 3 1.5版
或不带
-加入“,”

微软DCF MUI(英语)2013 Microsoft OneNote MUI(英语)2013 麦克风