Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Powershell / QuestCommandlets script that would extract user account information to a .CSV File

Posted on 2013-10-25
7
Medium Priority
?
687 Views
Last Modified: 2013-10-25
So, a script that could pull AD users if certain fields weren't populated?


Powershell / QuestCommandlets script that would extract user account information to a .CSV File.

These are the items:

Office
Street
City
Country
Job Title
Department
Manager
0
Comment
Question by:mjm21
[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
  • 4
  • 2
7 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39601181
Use the code below to accomplish what you have asked...

Import-module activedirectory
Get-ADUser -filter * -Properties * | select Name, Office, Street, City, Country, Title, Department, Manager | export-csv "c:\exportedUsers.csv"

Will.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39601258
script that could pull AD users if certain fields weren't populated?
Try...
Get-Qaduser -SizeLimit 0 | ? { 
 $_.Office -eq $null -or `
 $_.StreetAddress -eq $null -or `
 $_.City -eq $null -or `
 $_.Country -eq $null -or `
 $_.Title -eq $null -or `
 $_.Department -eq $null -or `
 $_.Manager -eq $null
} | Select Samaccountname,Office,StreetAddress,City,Country,Title,Department,Manager |
Export-csv C:\report.csv -NTI

Open in new window

Replace Get-Qaduser -SizeLimit 0 with Get-Aduser -filter * -Properties * to run it with MS AD PowerShell..
0
 

Author Comment

by:mjm21
ID: 39601347
Thanks going to test now!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:mjm21
ID: 39601449
Everything works fine except "country"
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39601471
Ok use CO or C instead of  country..
Get-Qaduser -SizeLimit 0 -ip CO | ? { 
 $_.Office -eq $null -or `
 $_.StreetAddress -eq $null -or `
 $_.City -eq $null -or `
 $_.CO -eq $null -or `
 $_.Title -eq $null -or `
 $_.Department -eq $null -or `
 $_.Manager -eq $null
} | Select Samaccountname,Office,StreetAddress,City,Co,Title,Department,Manager |
Export-csv C:\report.csv -NTI

Open in new window

0
 

Author Comment

by:mjm21
ID: 39601598
The CO did it.  Many Thanks!
0
 

Author Closing Comment

by:mjm21
ID: 39601601
Excellent Job!!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

610 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