Solved

Get-ADUser against txt file containing UPNs

Posted on 2016-10-19
1
40 Views
Last Modified: 2016-10-19
I have a txt file with UPNs, is there a way to run a Get-ADUser against that txt file and pull back UserPrincipalName,Enabled,SamAccountName,ObjectClass details via the Active Directory Module in AD, then export results to CSV.
0
Comment
Question by:Christian Hans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 41851152
Why get the ObjectClass?  It's always going to be "user".
Anyway, it's a pretty simple script.
Get-Content UPNs.txt | ForEach `
{
    Get-ADUser -Filter { UserPrincipalName -eq $_ } -Properties UserPrincipalName,Enabled,SamAccountName,ObjectClass
} | Select UserPrincipalName,Enabled,SamAccountName,ObjectClass |
 Export-CSV UserInfo.csv -NoTypeInformation

Open in new window

0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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