Created
May 2, 2017 21:34
-
-
Save anonymous/4d506f50f5a635fd442184c4c0707a87 to your computer and use it in GitHub Desktop.
Quick script to gather hardware and BIOS info on AD servers and export to CSV
This file contains 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
# Gather all servers | |
$servers = (Get-ADComputer -Filter *).name | |
# Create collection to capture results | |
$Results = @() | |
# Begin server loop | |
foreach ($server in $servers) { | |
# Test if machine is online | |
if (Test-Connection -ComputerName $server -Count 1 -Quiet -ErrorAction Stop) { | |
# Create object for each machine's results | |
$Result = New-Object -TypeName System.Object | |
$Result | Add-Member -MemberType NoteProperty -Name "Hostname" -Value $server | |
# Get system info | |
$system = Get-ciminstance -ClassName Win32_ComputerSystem -ComputerName $server | |
# Write properties to object | |
$Result | Add-Member -MemberType NoteProperty -Name "Mfg" -Value $system.Manufacturer | |
$Result | Add-Member -MemberType NoteProperty -Name "Model" -Value $system.Model | |
$bios = Get-ciminstance -ClassName win32_bios -ComputerName $server | |
$Result | Add-Member -MemberType NoteProperty -Name "BIOS Version" -Value $bios.SMBIOSBIOSVersion | |
} | |
else { | |
Write-Warning "$server is offline" | |
} | |
# Write result to the collection | |
$Results += $Result | |
} | |
$Results | ConvertTo-Csv -NoTypeInformation | Out-File ServerResults.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment