[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 63
  • Last Modified:

active directory

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
pramod1
Asked:
pramod1
  • 5
  • 2
  • 2
1 Solution
 
Joseph MoodyBlogger and wearer of all hats.Commented:
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
 
pramod1Author Commented:
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
 
pramod1Author Commented:
I mean all objects are in schema
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
pramod1Author Commented:
so from where other objects are being pulled in 1st command
0
 
Joseph MoodyBlogger and wearer of all hats.Commented:
everywhere in the first command. It doesn't have a searchbase parameter so it searches the entire domain.
0
 
pramod1Author Commented:
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
 
SubsunCommented:
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
 
pramod1Author Commented:
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
 
SubsunCommented:
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

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now