Twhite0909
asked on
Create AD Query for User name and User Creation Date
I am looking for an AD Query to List all Users and their creation dates. I need to export this to a CSV file to make a spreadsheet.
ASKER
So are we saying there is not an AD query to run and only PowerShell can achieve what Im looking for>?
No, I'm not saying that at all...Powershell is only one way to get you there...I'm sure there are other tools perhaps built-in ones. I only offered Powershell as a possible solution since that's what I'm familiar with. Maybe others can suggest other alternatives
ASKER
Im not that good with Powershell. On my DC there is a Active Directory Module for Powershell. I launched that. My domain is called AD.LOCAL so is this the right command:
Get-ADUser -SearchRoot "dc=ad,dc=local" `
-DontUseDefaultIncludedPro perties `
-IncludedProperties DN,SamAccountName,Name,whe nCreated `
-SizeLimit 0 |
Select-Object SamAccountName,whenCreated |
Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
Get-ADUser -SearchRoot "dc=ad,dc=local" `
-DontUseDefaultIncludedPro
-IncludedProperties DN,SamAccountName,Name,whe
-SizeLimit 0 |
Select-Object SamAccountName,whenCreated
Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
Try this
Get-ADUser -Properties * -SearchBase "DC=mydomain,DC=com" |
Select-Object SamAccountName,whenCreated |
Export-Csv "C:\myscripts\ADusers.csv" -NoTypeInformation
ASKER
That command asks for an entry for Filter. I hit Admin and it erroed:
PS C:\Users\WhiteT> Get-ADUser -SearchRoot "dc=ad,dc=local" `
>> -DontUseDefaultIncludedPro perties `
>> -IncludedProperties DN,SamAccountName,Name,whe nCreated `
>> -SizeLimit 0 |
>> Select-Object SamAccountName,whenCreated |
>> Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
>>
Get-ADUser : A parameter cannot be found that matches parameter name 'SearchRoo
t'.
At line:1 char:23
+ Get-ADUser -SearchRoot <<<< "dc=ad,dc=local" `
+ CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBind
ingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Mic rosoft.Act iveDirecto ry
.Management.Commands.GetAD User
PS C:\Users\WhiteT> Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
cmdlet Export-Csv at command pipeline position 1
Supply values for the following parameters:
InputObject: admin
Export-Csv : Could not find a part of the path 'C:\myscripts\ADusers.csv' .
At line:1 char:17
+ Export-Csv <<<< C:\myscripts\ADusers.csv -NoTypeInformation
+ CategoryInfo : OpenError: (:) [Export-Csv], DirectoryNotFoundEx
ception
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft. PowerShell .Commands. Ex
portCsvCommand
PS C:\Users\WhiteT>
PS C:\Users\WhiteT> Get-ADUser -SearchRoot "dc=ad,dc=local" `
>> -DontUseDefaultIncludedPro
>> -IncludedProperties DN,SamAccountName,Name,whe
>> -SizeLimit 0 |
>> Select-Object SamAccountName,whenCreated
>> Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
>>
Get-ADUser : A parameter cannot be found that matches parameter name 'SearchRoo
t'.
At line:1 char:23
+ Get-ADUser -SearchRoot <<<< "dc=ad,dc=local" `
+ CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBind
ingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Mic
.Management.Commands.GetAD
PS C:\Users\WhiteT> Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
cmdlet Export-Csv at command pipeline position 1
Supply values for the following parameters:
InputObject: admin
Export-Csv : Could not find a part of the path 'C:\myscripts\ADusers.csv'
At line:1 char:17
+ Export-Csv <<<< C:\myscripts\ADusers.csv -NoTypeInformation
+ CategoryInfo : OpenError: (:) [Export-Csv], DirectoryNotFoundEx
ception
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.
portCsvCommand
PS C:\Users\WhiteT>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
PERFECT!! That worked beautifully Thank you SO much!
http://www.quest.com/powershell/activeroles-server.aspx
Open in new window