-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-installed-software.ps1
24 lines (20 loc) · 1.01 KB
/
get-installed-software.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Gets all software installed on a list of servers, using WinRM
$Servers = @("Server1","Server2","Server3")
$ExportFile = "C:\temp\software.csv"
$script = {
$InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
$InstalledSoftware | Where-Object { $_.GetValue('DisplayName') } | Select-Object @{Name="Package";Expression={$_.GetValue('DisplayName')}}, @{Name="Version";Expression={$_.GetValue('DisplayVersion')}}
}
$AllSoftware = @()
foreach ($Server in $Servers) {
$result = Invoke-Command -ComputerName $Server -ScriptBlock $script -ErrorVariable "errorText" -ErrorAction SilentlyContinue
if ($errorText) {
Write-Host "Running on server $Server failed: $($errorText.ErrorDetails.Message)"
}
else {
Write-Host "Server $Server processed successfully"
$AllSoftware += $result
}
$errorText = $null
}
$AllSoftware | Select-Object -Property PSComputerName, Package, Version | Export-Csv -Path $ExportFile -Encoding utf8 -UseCulture