Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Generating report with enabled users with logon date.

$
0
0

Hello!

Im trying to generate a HTML report where i get the output og users that have not been logged in since 1/1/2015. I have managed to make the report and it looks good except for one thing...

I want the report to only output users that are enabled (so that i can disable them later with a .txt file and PS). Currently the my PowerShell script outputs all users that have not signed in since 1/1/2015.

Import-Module ActiveDirectory

Get-ADUser –filter * -prop LastLogonDate |
Where { $_.LastLogonDate –lt (Get-Date).AddDays(-257) } |
ConvertTo-HTML –PreContent 'Mulig-innaktive brukere' -PostContent 'Rapport utskrevet 14.09.2015' –Prop Name,LastLogonDate |
Out-File C:\Reports\InactiveUsers2.html

Nevermind the precontent and postcontent part.. Norwegian words :)

Is there anything i can add to my code to output only enabled users?

Thanks!



Viewing all articles
Browse latest Browse all 21975

Trending Articles