Solved

active directory

Posted on 2016-10-24
9
55 Views
Last Modified: 2016-10-24
PS C:\UsersUSERXXX> get-aduser -filter {objectclass -like "user"} | Measure-Object

I  just ran above  count on objectclass like “user” and it returned 8531 objects

and I ran Get-ADObject -Filter {name -like '*'} -SearchBase 'CN=Schema,CN=Configuration,DC=Fabrikam,DC=COM' -ResultSetSize $null | Measure-Object  and it gave 2786 objects

so what is the difference between those 2
0
Comment
Question by:pramod1
[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
  • 5
  • 2
  • 2
9 Comments
 
LVL 22

Expert Comment

by:Joseph Moody
ID: 41857295
The first one is only getting objects which are users. The second is getting every object in AD but only under the schema container.
0
 

Author Comment

by:pramod1
ID: 41857299
so the 1st one is getting all users  who are contacts users and users in domain who re also in schema?

and 2nd one is pulling users from only schema ? can you elaborate
0
 

Author Comment

by:pramod1
ID: 41857304
I mean all objects are in schema
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:pramod1
ID: 41857332
so from where other objects are being pulled in 1st command
0
 
LVL 22

Expert Comment

by:Joseph Moody
ID: 41857338
everywhere in the first command. It doesn't have a searchbase parameter so it searches the entire domain.
0
 

Author Comment

by:pramod1
ID: 41857354
I still didn't get it

1st command searches entire domain -that is fine

but the 2nd command searches users in schema only but all users I think are in schema>
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41857391
First command gives count of user objects for entire domain. Also Get-ADuser list only user objects so using -filter {objectclass -like "user"} will not do anything.

Second command lists all objects under 'CN=Schema' container, it does not contain any users objects. Schema container stores class and attribute definitions for all existing and possible Active Directory objects.
Ref : https://technet.microsoft.com/en-us/library/cc961744.aspx

To get user count using Get-ADObject, Try..
Get-ADObject -Filter {ObjectClass -eq "user" -and ObjectCategory -eq "Person"} | Measure

Open in new window

0
 

Author Comment

by:pramod1
ID: 41857431
1) Get-ADObject -Filter * -this pulled 16421 user objects
2)get-aduser -filter {objectclass -like "user"} | Measure-Object-  thsi pulled 8531 user objects
3) ADObject -Filter {name -like '*'} -SearchBase 'CN=Schema,CN=Configuration,DC=Fabrikam,DC=COM' -ResultSetSize $null | Measure-Object  -2786 objects

2nd one gave all user objects in domain-8531 user objects
3rd one gave all objects and attributes -2786 user objects in schema container

so how come 1st one gave -16421?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41857450
First command lists all objects not just users object..

Second command list just user objects..

Third command doesn't list any users objects, it lists the objects contains in schema container as I explained in my previous comment.

Hope it's clear..
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

717 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