Solved

Powershell script to see all users in domain

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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

695 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