Hi guys,
I need your help to create list of inactive accounts in AD for 30 days. Inactive or created accounts within 2 weeks are not included in the report. Report should be exported to HTML and it has a counter to count all the records and place it at the bottom of the report. Lastlogon should be displayed and other pertinent information for the accounts.
I'm starting with this command but I'm getting inaccurate result.
$a = "<style>"$a = $a + "BODY{background-color:darkseagreen;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"
Search-adaccount -usersonly -accountinactive -timespan 90.00:00:00 | where {$_.enabled} |select name, samaccountname,userprincipalname, enabled, lastlogondate,lockedout,passwordexpired,passwordneverexpires |ConvertTo-HTML -head $a | Out-File C:\Scripts\Test.htm
Invoke-Expression C:\Scripts\Test.htm
Thank you in advance for the help!