Having trouble exporting a table of information from Active Directory.
I'm pretty new to Powershell and I'm trying to gather and export a list of all the user's names, usernames, emails, last logon dates/times, and each security group each user is a member of. I have a one liner of code that has everything except the security group part. I tried looking around and couldn't find anything that I could easily implement into my code since I'm so new at this. Here's what I have so far.
import-module activedirectory
Get-ADUser -Filter * -Properties * | Select-Object -Property Name, SamAccountName, EmailAddress, @{Name="Last logon";Expression={[datetime]::FromFileTime($_.'LastLogon')}} | Sort-Object Name | Format-Table
Posted Sep 1, 2020, 9:35 PM UTC
24
You could use the Get-ADGroup cmdlet and Select the objects you want from each AD Group.