Created
September 24, 2020 12:31
-
-
Save debold/ffaaa7eb3c78aa18d97ee27efc44bb5f to your computer and use it in GitHub Desktop.
Collect a quick software inventory from all domain servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Servers = Get-ADComputer -Filter { OperatingSystem -like "*server*" -and Enabled -eq $true } -Properties OperatingSystem | |
$Results = @() | |
foreach ($Server in $Servers) { | |
Write-Host $Server.Name -NoNewline | |
try { | |
Test-Connection -ComputerName $Server.DnsHostName -Count 1 -ErrorAction Stop | Out-Null | |
$found = $true | |
Write-Host "`tfound`t" -NoNewline -ForegroundColor Green | |
} catch { | |
$found = $false | |
Write-Host "`tfailed`t" -NoNewline -ForegroundColor Red | |
} | |
if ($found) { | |
$Software = Get-WmiObject -Query "Select * from Win32_Product" -ComputerName $Server.DnsHostName | |
foreach ($Product in $Software) { | |
$Results += New-Object -TypeName PsObject -Property @{ | |
Server = $Server.Name; | |
Vendor = $Product.Vendor; | |
Software = $Product.Name; | |
Version = $Product.Version | |
} | |
} | |
} | |
Write-Host "done" | |
} | |
$Results | Export-Csv -Path .\Software.csv -Delimiter ";" -NoTypeInformation -Encoding Default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment