Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get List of Installed Software

Posted on 2013-10-22
9
Medium Priority
?
2,706 Views
Last Modified: 2013-10-25
Hello Experts!!!

I have an idea...  I think it would be awesome and I think powershell could do it.

Query all computers in a specific Active Directory OU for installed software and export it to a list of software.  While doing this, check to see if that software already exists on the list and if so, do not add it again... instead, put a +1 count in a column next to it.

So in the end, you'd have a list of software installed on all machines and how many machines have that software installed.

What do you think?  Is it doable?  Anyone willing to try making this one?  I'm going to start playing with it but am so slow when putting scripts together that I learn more from picking out the puzzle pieces from the experts!

Environment:  Windows 7 Enterprise SP1 x64
0
Comment
Question by:Irrylyn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39592322
Try...

Import-Module Activedirectory
$ErrorActionPreference = "SilentlyContinue"

$array = @()

Get-ADComputer -Filter * -SearchBase "OU=Comp,DC=Domain,DC=com" | % {

$pc = $_.Name

If (Test-Connection $pc -Count 2 -Quiet){
    
		Write-Host "Collecting List of Installed Software from $pc"
		
    $UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" 
    $reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$pc) 
    $regkey=$reg.OpenSubKey($UninstallKey) 
    $subkeys=$regkey.GetSubKeyNames() 
    
		foreach($key in $subkeys){

        $thisKey=$UninstallKey+"\\"+$key 

        $thisSubKey=$reg.OpenSubKey($thisKey) 

        $array += New-Object PSObject -Property @{
        ComputerName = $pc
	DisplayName = $($thisSubKey.GetValue("DisplayName"))
	Version = $($thisSubKey.GetValue("DisplayVersion"))
        }

    } 
	}
}
$array | ? {$_.DisplayName} | Select  ComputerName,DisplayName,Version | Export-Csv C:\temp\AllSoftlist.csv -NTI
$array | ? {$_.DisplayName} | Group DisplayName,Version -NoElement | Select Name,Count | Export-Csv C:\temp\AllSoftCount.csv -NTI

Open in new window

0
 
LVL 50

Expert Comment

by:jcimarron
ID: 39592329
0
 

Author Comment

by:Irrylyn
ID: 39592619
jcimarron:

Yes, I came accross that article thank you.  However, my environment has 10k computer systems so this will not be sufficient.

Subsun:

In the tests I did it seems to work very well.  However, a lot of software is left out because it doesn't have all of the software listed that is in 'Programs and Features.'  I believe this is because most of the software is listed under:

HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\

Problem with this is that Windows updates also show up there, so if we were to add that registry key to the script it would return a butt-load of KB's also....  any way to add that other reg location and filter out the updates?  I'm looking for a key or naming convention that matches them all to use as a filter.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:Irrylyn
ID: 39592650
It looks like the answer is in the keys.

Keys for system updates or .NET seem to end with the KB#,  for example:

HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F5B09CFD-F0B2-36AF-8DF4-1DF6B63FC7B4}.KB2737019


Keys for Office applicaiton updates seem to use the same key number and then tag more to it.  For example:

MS Office 2007 key:  HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{90120000-0011-0000-0000-0000000FF1CE}

MS Office 2007 Update:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{90120000-0011-0000-0000-0000000FF1CE}_PROPLUS_{0B7B13E7-52F2-44C8-84BC-5B9C563AA572}
0
 

Author Comment

by:Irrylyn
ID: 39594269
Anyone know how to add the wow6432node uninstall key to this?

I'll take just that and manually remove the KB's/updates if needed.


Maybe to remove the updates, something like Where-Object {not ( $_.AppID -like "KB*") }
0
 
LVL 40

Accepted Solution

by:
Subsun earned 1900 total points
ID: 39594451
hey sorry, i was a bit busy.. :-).. try this and see if it works as expected...

Import-Module Activedirectory
Function Get-Soft ($Regpath,$PC){
Try {
	$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::'LocalMachine', $PC)
		
	#connect to the needed key :

	$regKey = $reg.OpenSubKey($Regpath)

	#and list the properties :

	$programs = $regkey.GetSubKeyNames()
	foreach ($program in $programs)
	{
	    $Soft = ($regKey.OpenSubKey($program)).GetValue("DisplayName")
			$Version = ($regKey.OpenSubKey($program)).GetValue("DisplayVersion")
			If ($Soft -notmatch "Update" -and $Soft -ne $null){
	    New-Object PSObject -Property @{
			ComputerName = $PC
			DisplayName = $Soft
			Version = $Version
				}
			}
		}
	}
	Catch [Exception]{
	Write-Host "Collecting information from Computer $PC - Error : $($_.Exception.Message)" -ForegroundColor Red
	}
}

$array = Get-ADComputer -Filter * -SearchBase "OU=Comp,DC=Domain,DC=com" | % {

$PC = $_.Name
Write-Host "Collecting information from Computer $PC" -ForegroundColor Green

	"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\",`
	"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" | % {
	Get-Soft $_ $PC
	}
}| Select ComputerName,Version,DisplayName -Unique

$array | ? {$_.DisplayName} | Select  ComputerName,DisplayName,Version | Export-Csv C:\temp\AllSoftlist.csv -NTI
$array | ? {$_.DisplayName} | Group DisplayName,Version -NoElement | Select Name,Count | Export-Csv C:\temp\AllSoftCount.csv -NTI

Open in new window

0
 
LVL 41

Assisted Solution

by:footech
footech earned 100 total points
ID: 39594639
It may not be important in your case, but don't forget that there can also be entries in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall and this can vary by the logged in user.
0
 

Author Comment

by:Irrylyn
ID: 39595694
footech:  thank you, that is a good point and now that I know how, I will plug it in and try that out.

Subsun:  What you do is art.  I am still floored at how quickly you did that!  And it works beautifully.  I love the addition of the error colors and descriptions if a host could not be reached.  It helps identify those that are offline versus those with configuration issues.  I also see the -notmatch that you used and paired it with $Soft -ne null.  Works great!  Last, I have to commend you for the -Unique addition as it eliminated a lot of duplicates I saw previously.

Well done!

I will do some homework on functions and arrays.  Very useful stuff, but imtimidating!
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39600630
Glad to hear my solution works for you and has some added value!..  indeed, I learned a lot on EE.. :-)
0

Featured Post

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question