Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

PowerSQL By Prashanth Jayaram

Technology enthusiast with 7+ years of experience in Database Technology. I am Microsoft Certified Professional with certificates of OCA, MCP, MCTS, MCITP developer, MCITP administration and backed with a degree in Master of Computer Application. My expertise lies in T-SQL programming, Replication, PowerShell and Performance Tuning. Hobbies are Drawing, playing soccer and listening to Melodies songs.

PowerShell – List Local or Remote Programs with an Exclusion List of Programs

This post is to list all the software installed on your local or remote machines. The exclusion list is an array item which holds the programs  that you wanted to exclude it from displaying.

********************************************************************************

Function Get-SoftwareList {
param(
[CmdletBinding()]
[string[]]$ComputerName = $env:COMPUTERNAME
)

$writeArray=@()
$excludeArray=@()
#List of programs to exclude
$excludeArray = (“Security Update for Windows”,
“Update for Windows”,
“Update for Microsoft .NET”,
“Security Update for Microsoft”,
“Hotfix for Windows”,
“Hotfix for Microsoft .NET Framework”,
“Hotfix for Microsoft Visual Studio 2007 Tools”,
“Hotfix”)
foreach ($Computer in $ComputerName) {
$RegBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Computer)
$RegUninstall = $RegBase.OpenSubKey(‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall’)
$RegUninstall.GetSubKeyNames() |
ForEach-Object {
$DisplayName = ($RegBase.OpenSubKey(“SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$_”)).GetValue(‘DisplayName’)
$donotwrite = $false
if (($DisplayName -ne “”) -and ($DisplayName -ne $null)) {

Foreach($exclude in $excludeArray)
{
if($DisplayName.StartsWith($exclude) -eq $TRUE)
{
$donotwrite = $true
break
}
}
if ($donotwrite -eq $false)
{
$writeArray +=New-Object -TypeName PSCustomObject -Property @{
ComputerName = $Computer
ProgramName = $DisplayName }
}
}
}

}

$column1 = @{expression=”ComputerName”; width=12; label=”ComputerName”; alignment=”left”}
$column2 = @{expression=”ProgramName”; width=120; label=”ProgramName”; alignment=”left”}
$writeArray|format-table $column1, $column2
$writeArray.GetEnumerator() | Out-GridView -Title “Software List”
}

********************************************************************************

Download here SoftwareList

Example 1 – Local Machine

PS:\>Get-SoftwareList

Example 2 -Remote computer

PS:\>Get-SoftwareList -ComputerName <COMPUTERNAME>

Example 3- Remote Computers

PS:\>Get-SoftwareList -ComputerName <COMPUTERNAME1,COMPUTERNAME2….>

Output -

SoftWareList


Comments

Leave a comment on the original post [sqlpowershell.wordpress.com, opens in a new window]

Loading comments...