Solved

AD System Login Report (Extract) -

Posted on 2014-11-20
4
154 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 16

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 16

Accepted Solution

by:
Learnctx earned 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Viewers will learn how to create a PivotTable and make basic changes to it in Excel 2013.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now