I've got the following code working to list AD group members by specific group and retrieve their properties. I need to create a report though and seperate it into three seperate sections - accounts logged in within 30 days, accounts not logged in within 30 days, and disabled accounts.
Get-ADGroupMember My_Group | GetADUser -Properties samaccountname, emailaddress, description, lastlogondate | Select samaccountname, emailaddress, description, lastlogondate
When I've ran it off as well I plan to convert the output to HTML and email the report. Emailing it is straightforward and converting it to HTML seems so as well using the -fragment switch and a bit of CSS.
What's the best way to go about seperating the listed members into three categories while keeping the existing working code? For example, adding a 'where account disabled' to the end of that line. Or 'where last logged on' meets a certain criteria? I could
run the command three times or perform an operation on just the one. It'd run once a month overnight against less than 100 users so no massive performance hit.
Thanks in advance