Powershell commands

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!

July 30th, 2015 1:44am

Check this link.

https://gallery.technet.microsoft.com/

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 1:48am

Hi,

" I'm getting inaccurate result", what is expected and what are you getting.

If you leave the html part now, is the Search-ADAccount resulting the correct data.

July 30th, 2015 2:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics