Created
June 20, 2012 23:04
-
-
Save mekuls/2962799 to your computer and use it in GitHub Desktop.
Get's a list of installed software on a system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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