Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

AD System Login Report (Extract) -

Posted on 2014-11-20
4
Medium Priority
?
164 Views
Last Modified: 2014-11-25
Hello,
Is there a way to extract some kind of report / list of domain usernames (system login) ,, using only either the first name and last name ,, or Display Name
?
using power shell ,, or something else?
Thanks
-
-
,,
0
Comment
Question by:mvalencia2003
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Learnctx
ID: 40456825
Yes you can do this with Powershell. If you're running Server 2008 R2 you can do this using the AD cmdlets easily.

Import-Module ActiveDirectory
Get-ADUser -Filter {givenName -eq "John" -and sn -eq "Smith"} | Select Name, sAMAccountName, givenName, sn | Export-Csv -Notype -Path C:\Temp\Results.csv
## or
Get-ADUser -Filter {displayName -eq "Smith, John"} -Properties displayName | Select Name, sAMAccountName, givenName, sn, displayName | Export-Csv -Notype -Path C:\Temp\Results.csv

Open in new window


You can do it from an import csv file as well.
0
 
LVL 4

Author Comment

by:mvalencia2003
ID: 40457092
what if I have list of Display Names in an excel file , how is this done ,,
?
?
0
 
LVL 18

Accepted Solution

by:
Learnctx earned 2000 total points
ID: 40459056
I'll need to make some assumptions here. So I'll assume that you have a text file with display names? Would that be accurate? Or is it a CSV?

## For a flat text file with display names
Get-Content c:\temp\displaynames.txt | Foreach-Object {
   Get-ADUser -Properties displayName -Filter {displayName -eq $_} 
} | Select-Object Name, sAMAccountName, displayName | Export-Csv -NoType c:\temp\results.csv

## For a CSV file with displayname as a header
Import-Csv c:\temp\displaynames.csv | Foreach-Object {
   Get-ADUser -Properties displayName -Filter {displayName -eq $_.displayName} 
} | Select-Object Name, sAMAccountName, displayName | Export-Csv -NoType c:\temp\results.csv

Open in new window

0
 
LVL 4

Author Closing Comment

by:mvalencia2003
ID: 40464276
,,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question