Solved

Get-ADUser against txt file containing UPNs

Posted on 2016-10-19
1
24 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
1 Comment
 
LVL 39

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

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

Suggested Solutions

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

919 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

19 Experts available now in Live!

Get 1:1 Help Now