Skip to content

Instantly share code, notes, and snippets.

@mekuls
Created June 20, 2012 23:04
Show Gist options
  • Save mekuls/2962799 to your computer and use it in GitHub Desktop.
Save mekuls/2962799 to your computer and use it in GitHub Desktop.
Get's a list of installed software on a system
Param(
[Parameter(Mandatory=$true)]
$FilePath
)
$computername=$env:COMPUTERNAME
$uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computername)
$regkey = $reg.OpenSubKey($uninstallKey)
$subkeys = $regkey.GetSubKeyNames()
$output = @()
$filterList = @(
'Windows Server'
,'Citrix Hotfix'
,'Security Update for Microsoft'
,'Hotfix for Microsoft'
,'Security Update for Windows'
,'Update for '
)
foreach ($key in $subkeys)
{
$cntKey = $uninstallKey+"\\"+$key
$cntSubKey = $reg.OpenSubKey($cntKey)
$displayName = $cntSubKey.GetValue("DisplayName")
if ($displayName -ieq $null) { continue }
$compliance = $true
foreach ($subStr in $filterList)
{
if ($displayName.ToLower().Contains($subStr.ToLower()))
{
Write-Host "Filtering entry " + $displayName
$compliance = $false
}
}
if ($compliance -ieq $true)
{
$o = New-Object PSObject
$o | Add-Member -MemberType NoteProperty `
-Name "ComputerName" `
-Value $computername
$o | Add-Member -MemberType NoteProperty `
-Name "Software" `
-Value $displayName
$output += $o
}
}
$output | Export-Csv -Path $FilePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment