Link to home
Start Free TrialLog in
Avatar of cj_cb
cj_cb

asked on

Powershell AD query script needed

Need a powershell script to get these fields and save to csv.

Username
Group membership
Last login
Display name
OU
Enabled/disabled
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cj_cb
cj_cb

ASKER

yes just a comma-seperated list is good, i will look into Quest but we are 2008r2 active domain.
Then we can use the ActiveDirectory module, and the Get-AD* cmdlets ...
Avatar of cj_cb

ASKER

that may work, was hoping for a little more detail on how to use the cmdlet.
Sorry, I wasn't finished, but had to leave.
Something like this?
Import-Module ActiveDirectory
Get-ADUser -Filter * -Properties * |
  select Name,
        @{n='Group Membership'; e={($_.MemberOf | % {(get-adgroup $_).Name}) -join ','}},
        LastLogonDate, DisplayName, DistinguishedName, Enabled |
  Export-CSV 'C:\Results.csv'

Open in new window