Need Help with Powershell Commandlet

Hey I am trying to create a file that has the following command

-GetADGroupMember

I need the username, last login and status.

Anyone good with powershell out there?

https://www.reddit.com/r/PowerShell/comments/2fy2i5/list_last_logon_date_from_users_of_a_specific/

this should give you a couple of examples just need to add status to the command.

2 Likes

Hey that actually helped a lot, thank you. I ended using this to get the report I wanted:

Get-ADGroupMember | foreach {Get-ADUser -Identity $_.distinguishedname -Properties displayname, samaccountname, lastlogondate, enabled | select displayname, samaccountname, lastlogondate, enabled}

Now when I wanted to get it put into a csv I did this:

Get-ADGroupMember | foreach {Get-ADUser -Identity $_.distinguishedname -Properties displayname, samaccountname, lastlogondate, enabled | select displayname, samaccountname, lastlogondate, enabled} | Export-Csv -C:\Users\Administrator\Desktop\Domain Users\Data.csv

I got an error that said parameter binding exception. I am guessing I need more than just the pathway for the csv file. Any thoughts on how to set this up for a export-csv?

Ok put on my big boy pants and used Reddit search. That sub-redit is incredibly helpful. Thanks for pointing me to that and for all your help!

Did you get it working? try with the following:

Get-ADGroupMember -Identity "Domain Admins" | foreach {Get-ADUser -Identity $_.distinguishedname -Properties displayname, samaccountname, lastlogondate, enabled | select displayname, samaccountname, lastlogondate, enabled} | Export-Csv C:\Users\Administrator\Desktop\Data.csv

Ricardo

Hey Ricardo I did get it to work. I ended up using this:

Get-ADGroupMember | foreach {Get-ADUser -Identity $_.distinguishedname -Properties displayname, samaccountname, lastlogondate, enabled | select displayname, samaccountname, lastlogondate, enabled} | Export-Csv -path “C:\Users\Administrator\Desktop\Domain Users\Data.csv”

The difference was including ‘-path’ into the command. The CSV looked great though

1 Like