Looking for a PowerShell Script that can output result of all machines that are offline after a massive power outage. I found one script online, sample script below, that outputs all machines that are offline in red, however when trying to output the results to .csv they're all the same default black color. Can a column be added to this script that says "offline" next to the machines that are registering in red? If this isn't an option could a script be made to show this. I'll basically take this list and hand off to others so they can go around and power on these machines since we a number of employees not in the office.
Import-Module active*
$rtn = $null
Get-ADComputer -Filter * |
ForEach-Object {
$rtn = Test-Connection -CN $.dnshostname -Count 1 -BufferSize 16 -Quiet
IF($rtn -match ‘True’) {write-host -ForegroundColor green $.dnshostname}
ELSE { Write-host -ForegroundColor red $_.dnshostname }
}