Solved

AD System Login Report (Extract) -

Posted on 2014-11-20
4
157 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 17

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 17

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

777 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