I started today to play with PowerShell and wanted to do a simple task. Read all my installed software, filter out "Microsoft related entries + null entries" and store them in JSON file.
Well, I was able to do that but I couldn't figure out the filtering part mostly because the whole script language is new to me and I couldn't successfully iterate to remove the entries I wanted.
Your help is appreciated!
$outputFile="C:\test.JSON"
$GetAppData= Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* |Select-Object DisplayName, DisplayVersion, InstallDate
foreach ($Applications in $GetAppData.PSObject)
{
foreach ($App in $Applications.Properties.Value)
{
if ($App.'DisplayName' -like '*Microsoft*' -or !$App.'DisplayName' )
{
$Applications.Value.PSObject.Properties.Remove($App)
}
}
}
$GetAppData| ConvertTo-Json -Depth 100 | Set-Content -Path $outputFile -Force
!$App.'DisplayName', as a means of it being null/empty?