Solved

Powershell script to see all users in domain

Posted on 2014-07-25
4
300 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I previously wrote an article addressing the use of UBCD4WIN and SARDU. All are great, but I have always been an advocate of SARDU. Recently it was suggested that I go back and take a look at Easy2Boot in comparison.
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

733 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