Solved

Get-ADUser against txt file containing UPNs

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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 …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

739 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