Link to home
Start Free TrialLog in
Avatar of SAM IT
SAM IT

asked on

Need to export the list of AD users with below attrubutes

Below script export the created and disabled AD users for last one day. When remove the filter and run the script to export all the AD users using same attributes its not working, Thanks in advance

$FilterDate = (Get-Date).AddDays(-1).Date
$NetBIOSDomain = (Get-ADDomain).NetBIOSName
Get-ADUser -Filter {(whenCreated -ge $FilterDate)} -Property UserPrincipalName, Enabled, Mail, l, physicalDeliveryOfficeName, telephoneNumber, extensionAttribute9, State, c, co, msExchRecipientTypeDetails, co, Manager, whenCreated, whenChanged |
	Select-Object -Property SamAccountName, @{n='NTAccountName'; e={"$($NetBIOSDomain)\$($_.SamAccountName)"}}, UserPrincipalName, Enabled, WhenCreated, WhenChanged, extensionAttribute9, State, c, co, msExchRecipientTypeDetails, Mail, @{n='City'; e={$_.l}}, physicalDeliveryOfficeName, TelephoneNumber, @{n='Country'; e={$_.co}}, Manager, DistinguishedName, @{n='ParentContainer'; e={($_.DistinguishedName -split '(?<!\\),', 2)[1]}} | Export-Csv C:\out.csv

Open in new window

Avatar of oBdA
oBdA

"Filter" is a mandatory argument if you're not querying using -Identity; to get all users, use -Filter *
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland 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