71 lines
2.6 KiB
PowerShell
71 lines
2.6 KiB
PowerShell
######################################################################
|
|
#
|
|
# List-Software.ps1
|
|
#
|
|
# PowerShell-Script to list and classify installed software
|
|
# Version: 1.0, 25.10.2009
|
|
#
|
|
# Input-csv-file: List-Software-Classifications.txt
|
|
# Format: SoftwareClass,PartOfName
|
|
# Examples: "FreeWare","Adobe Reader"
|
|
# "Software","Microsoft Office Enterprise 2007"
|
|
# "Driver","SigmaTel Audio"
|
|
# "MS-Components","Microsoft .NET"
|
|
#
|
|
# (c) 2009, Andreas Lauer IT Service, www.alits.de
|
|
# Free Usage for www.powershell-ag.de
|
|
#
|
|
######################################################################
|
|
|
|
#-----------------------------------------------------------------
|
|
# Functions
|
|
#-----------------------------------------------------------------
|
|
|
|
Function Get-SoftwareList {
|
|
#Get All Users Software-List
|
|
$Keys = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
|
|
$SoftwareMachine = @($Keys | foreach-object {Get-ItemProperty $_.PsPath})
|
|
Write-Host "Count of Software for All Users:" $SoftwareMachine.Count
|
|
|
|
#Get Current User Software-List
|
|
$Keys = Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
|
|
$SoftwareUser = @($Keys | foreach-object {Get-ItemProperty $_.PsPath})
|
|
Write-Host "Count of Software for Current User:" $SoftwareUser.Count
|
|
|
|
#Add both Software-Lists
|
|
$SoftwareAll = $SoftwareMachine + $SoftwareUser
|
|
Write-Host "Total Count of Software:" $SoftwareAll.Count
|
|
|
|
#Drop SystemComponents and Software with empty Name
|
|
$Software = ($SoftwareAll | Where-Object {(($_.DisplayName+" ") -ne " ") -and ($_.SystemComponent -ne 1)}| Sort-Object DisplayName)
|
|
Write-Host "Count of Installed Software:" $Software.Count
|
|
|
|
#Import csv-File with Software-Classifications - to be edited
|
|
$ClassificationListFile = "List-Software-Classifications.txt"
|
|
$ClassificationList = Import-Csv $ClassificationListFile
|
|
|
|
#Classify Software, use Property "PsPath" for Classification-Text
|
|
foreach ($Item in $Software) {
|
|
$Item.PsPath = "**unknown**"
|
|
foreach ($Class in $ClassificationList) {
|
|
if (($Item.DisplayName+" ").Contains($Class.PartOfName)) {
|
|
$Item.PsPath = $Class.SoftwareClass
|
|
Break
|
|
}
|
|
}
|
|
}
|
|
|
|
#Output
|
|
$Software | ft PsPath, DisplayName, DisplayVersion, Publisher, InstallDate -AutoSize | Out-File SoftwareList.txt
|
|
$Software | select-object PsPath, DisplayName, DisplayVersion, Publisher, InstallDate | Export-Csv SoftwareList.csv -NoTypeInformation
|
|
}
|
|
|
|
#-----------------------------------------------------------------
|
|
# Main program
|
|
#-----------------------------------------------------------------
|
|
|
|
Clear-Host
|
|
Write-Host "Starting ..."
|
|
Get-SoftwareList
|
|
Write-Host "... Done."
|