I run the following code using powershell to get a list of add/remove programs from the registry:
gci -path hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object -Process { write-output $_.GetValue("DisplayName") } | out-file addrem.txt
I want the list to be separated by newlines per each program. I've tried:
gci -path hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object -Process { write-output $_.GetValue("DisplayName") `n } | out-file test.txt
gci -path hklm:\software\microsoft\windows\currentversion\uninstall | ForEach {$_.GetValue("DisplayName") } | write-host -Separator `n
gci -path hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object -Process { $_.GetValue("DisplayName") } | foreach ($_) { echo $_ `n }
But all result in weird formatting when output to console, and with three square characters after each line when output to file.
I tried Format-List, Format-Table, and Format-Wide with no luck.
Originally, I thought something like this would work:
gci -path hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object -Process { "$_.GetValue("DisplayName") `n" }
But that just gave me an error...