We are doing software housekeeping on our Windows 2003 servers in preparation to migrate to higher release
I need to retrieve the installed software from these boxes.
Instead of the if statement below, I would like to use an array as follows. Thank you in advance.
$OmitSoft = @("", "\(KB", "McAfee ", "HP ", "Service Pack", "IBM ", "Internet Explorer", .......,"VMware ")
$UninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
ForEach ($key in $SubKeys) {
$thisKey = $UninstallKey+"\\"+$key
$thisSubKey = $reg.OpenSubKey($thisKey)
$DisplayName = $($thisSubKey.GetValue("DisplayName")).Trim()
if (-not ($DisplayName -match "\(KB") -and ($DisplayName -ne "") -and ($DisplayName -match "McAfee") -and `
($DisplayName -notmatch "HP ") -and ($DisplayName -notmatch "Internet Explorer")) {
$ObjData = New-Object PsObject -Property ([ordered]@{
"ServerName" = $ComputerName
"Virtual" = $Virtual
"OSName" = $DisplayName
"OSVersion" = $($thisSubKey.GetValue("DisplayVersion"))
"Description" = $($thisSubKey.GetValue("Publisher"))
})
Export-Csv -InputObject $ObjData -NoTypeInformation $CsvFile -Force -Append
}
}
Learning PowerShell scripting