Solved

Powershell script to see all users in domain

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

Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

I wrote an article (http://www.experts-exchange.com/articles/2245/Anti-rootkit-software.html) some time ago with a reference to nLite  (http://www.nliteos.com/)slipstreaming software.  I recently changed that link to point to NTLite (https://www.ntl…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now