This code is giving me a html output of the adcomputer names. Im pretty sure it has to do with my if else. Really appreciate your time!
http://pastebin.com/raw.php?i=2PMxfxK9
$Header = @"
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
TR:Nth-Child(Even) {Background-Color: #dddddd;}
TR:Hover TD {Background-Color: #C1D5F8;}
$Title
"@
Import-Module ActiveDirectory
if ((Get-ADComputer -filter * -Property *| Select-Object ipv4addres) -eq $null) {
$a = Get-ADComputer -filter * -Property * | Select-Object name, dnshostname, operatingsystem, operatingsystemservicepack, ipv4address, lastlogondate, logoncount, @{ label = "PingResults"; Expression = { "Computer is OFF" } } | sort lastlogondate -Descending | ConvertTo-Html -head $header -Fragment
} else {
$b = get-adcomputer -filter * -Property * | Select-Object name, dnshostname, operatingsystem, operatingsystemservicepack, ipv4address, lastlogondate, logoncount, @{ label = "PingResults"; Expression = { tnc $_.ipv4address -InformationLevel Quiet } } | sort lastlogondate -Descending | ConvertTo-Html -head $header -fragment
}
ConvertTo-Html -head $header -Body $a $b -Title "Domain Inventory" | Out-File c:\test.html