New
#1
PS - List ALL Installed Programs using HKLM & HKCU.
Yesterday, I was tidying up some of my files, and came across a.bat
file that I use to output ALL the installed Programs which uses the REG KeysHKLM
&HKCU
. It works brilliantly, but the code is long and complicated. It involves compiling and exporting the data to a temp file, sorting it, and then importing it and creating the output file [ I can post if needed ].
Anyway, I thought that I would try and find a simplerPowerShell
solution, which I have, sort of.
This outputs ALL the required data [ exactly the same as my .bat file ], but, in three sections. Each section has a heading followed by the data. What I would like for it to do is to just output ONE heading, sorted uniquely alphabetically. As I said, I have been working on this yesterday and today and I am stumped.
Code:$Destination_File = 'C:\Users\System-Admin\Desktop\123.txt' if (Test-Path $Destination_File) {Remove-Item $Destination_File} Get-ChildItem -Path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Sort-Object -Property DisplayName | Select-Object -Property DisplayName, DisplayVersion, InstallLocation | Out-file -FilePath $Destination_File Get-ChildItem -Path HKCU:Software\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Sort-Object -Property DisplayName | Select-Object -Property DisplayName, DisplayVersion, InstallLocation | Out-file -FilePath $Destination_File -Append Get-ChildItem -Path HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Sort-Object -Property DisplayName | Select-Object -Property DisplayName, DisplayVersion, InstallLocation | Out-file -FilePath $Destination_File -Append (Get-Content -Path $Destination_File).Length -2 | Out-file -FilePath $Destination_File -Append
The.Length -2
is obviously to ignore the TWO lines Title.
Thanks.
I have made some progress, I have just found| Format-Table -Hide
. Now to try andSort
and ADD theTitle
back.
Last edited by Paul Black; 29 Oct 2021 at 09:20.