Produce a nice output of our best guess at all the installed applications on a server or PC.
$ComputerName = 'SQLPROD'
# Get Software list for a 64-bit computer SOFTWARE
$remoteCommand = @"
Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*
"@
$scriptBlock = [Scriptblock]::Create($remoteCommand)
# Test 1
$Software1 = Invoke-Command -Computername $ComputerName -Scriptblock $ScriptBlock
# Get Software list for a computer Wow6432Node
$remoteCommand = @"
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
"@
$scriptBlock = [Scriptblock]::Create($remoteCommand)
# Test 2
$Software2 = Invoke-Command -Computername $ComputerName -Scriptblock $ScriptBlock
$ComputerSoftwareList = [Pscustomobject]@()
if ($Software1) {
$ComputerSoftwareList += $Software1 | Sort-Object DisplayName
$ComputerSoftwareList.Count
}
if ($Software2) {
$ComputerSoftwareList += $Software2 | Sort-Object DisplayName
$ComputerSoftwareList.Count
}
$ComputerSoftwareList.Count
$OutGrid = $ComputerSoftwareList |
Sort-Object DisplayName |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate -Unique
$Global:seq = 1
$OutGrid |
Select-Object @{n=“Seq”; e={$Global:seq; $Global:seq++;}},
@{n="Computer";e={"$ComputerName"}}, DisplayName, DisplayVersion, Publisher, InstallDate |
Out-GridView
