Solved

Powershell script to see all users in domain

Posted on 2014-07-25
4
290 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
  • 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

0
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

825 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