?
Solved

Powershell script to see all users in domain

Posted on 2014-07-25
4
Medium Priority
?
315 Views
Last Modified: 2014-07-25
New to Powershell.  I have been playing around with it learning basic cmdlets from the internet.  Currently I did this.  
Get-ADObject -Filter { ObjectClass -eq 'organizationalunit' } -Properties CanonicalName | Select-Object -Property CanonicalName ........   And I got what I needed from it with this..  (not all shown but get the idea

oxarc1.int/*RDS USERS/Spokane                                                                                                                                              
oxarc1.int/*RDS USERS/Pasco    
oxarc1.int/*RDS USERS     ****                                                                                                                                                
oxarc1.int/*DESKTOPS/Desktop Users
oxarc1.int/*DESKTOPS/Desktop Computers  ******

What I need now is to list the users that are in each OU and import to txt file or csv .  Specifically the RDS USERS OU that I starred.  And an explanation on how to filter to each OU.   I would also like to get a report listing all the computers like I also starred in Desktop computers.  As you can see, computers and users are within the DESKTOPS OU.  So filtering is needed.  I will continue to research internet, but boss wouldn't mind a report of all users in my Active Directory.  And computers for that matter.  I hope I explained this ok.
0
Comment
[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
  • 3
4 Comments
 
LVL 4
ID: 40219837
I forgot to mention that I am using the PowerShell ISE.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40219871
To start with, you can use the following commands to get the report on users and computers.. You can open the csv files in excel and filter it based on OU.. Let me know if you need any modification in output..

Get-ADComputer -F * -pr canonicalname  | Select *,@{n='OU';e={$_.canonicalname -replace "/$($_.cn)",""}} | Export-Csv C:\Computer.csv -nti

Open in new window

Get-ADUser -F * -pr canonicalname  | Select *,@{n='OU';e={$_.canonicalname -replace "/$($_.cn)",""}} | Export-Csv C:\User.csv -nti

Open in new window

1
 
LVL 4
ID: 40219913
Outstanding.  I can work with that.  I have a lot of work to do learning this.  Looks really Greek to me,  especially from what I have seen from Internet examples.  You are truly an expert.  I think I need to find a book to show me what that all means in your solution!!.   But thank you so much,  I can work in Excel to get what I need!!  Looks like Powershell is pretty powerful.
0
 
LVL 4

Author Closing Comment

by:get-ADuser -F ($_.Name -eq "Todd")
ID: 40219917
A+
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
Suggested Courses

800 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