Solved

Get-ADUser against txt file containing UPNs

Posted on 2016-10-19
1
18 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
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 tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

706 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

20 Experts available now in Live!

Get 1:1 Help Now