Quantcast
Viewing latest article 22
Browse Latest Browse All 120

A PowerShell function to compare installed software

Earlier this week I posted a fuction to get the installed software.
Naturally the next step is to compare installed software over multiple targets once you’ve got the results of that function.
So, here’s a function which utilizes the Get-InstalledSoftware function I posted earlier.

function Compare-InstalledSoftware {
    param (
        [parameter(mandatory=$true)][array]$ComputerName
    )
    $AllInstalledSoftware = Get-InstalledSoftware -ComputerName $ComputerName
    $AllInstalledSoftwareNames = $AllInstalledSoftware | select -ExpandProperty 'Name' -Unique
    foreach ($Computer in $ComputerName) {
        $ComputerInstalledSoftware = $AllInstalledSoftware | Where-Object {$_.ComputerName -eq "$Computer"} | select -ExpandProperty 'Name' -Unique
        Compare-Object $AllInstalledSoftwareNames $ComputerInstalledSoftware | select -ExpandProperty InputObject -Unique | foreach {
            $Object = New-Object -TypeName PSObject
            $Object | Add-Member -MemberType NoteProperty -Name 'ComputerName' -Value $Computer
            $Object | Add-Member -MemberType NoteProperty -Name 'Name' -Value $_
            $Object
        }
    }
}

But… Dave Wyatt made a good comment no my Get-InstalledSoftware post which made me revise that function.
So wouldn’t I need to also revise this Compare-InstalledSoftware function? No.
Since I’m rather consistent in my output (ComputerName & Name) it works in both cases. Image may be NSFW.
Clik here to view.
:-)


Viewing latest article 22
Browse Latest Browse All 120

Trending Articles