How to get count of all schema attributes/classes

This topic contains 6 replies, has 3 voices, and was last updated by  Jeff Taylor 1 year, 9 months ago.

  • Author
  • #48762

    Jeff Taylor

    I am wanting to gather a count of all current AD Schema classes (attributeSchema, classSchema) prior to my Schema extension (Exchange 2013) in order to run a compare count, post-schema extension.

    I was going to put this current count into a variable, run the schema update, then populate a new variable, then run DIFF between the two to see the number added.

    I have this so far but clearly am not finding my classes:

    $schema =[DirectoryServices.ActiveDirectory.ActiveDirectorySchema]::GetCurrentSchema()


  • #48768

    $schemaPath = (Get-ADRootDSE).schemaNamingContext
    Get-ADObject -filter * -SearchBase $schemaPath -Properties * | Group-Object ObjectClass

    Should return something like this

    Count Name                      Group                                                                                                                 
    ----- ----                      -----                                                                                                                 
        1 dMD                       {CN=Schema,CN=Configuration,DC=home,DC=local}                                                                         
     1473 attributeSchema           {CN=FRS-Extensions,CN=Schema,CN=Configuration,DC=home,DC=local, CN=ms-DS-Resultant-PSO,CN=Schema,CN=Configuration,D...
      264 classSchema               {CN=CRL-Distribution-Point,CN=Schema,CN=Configuration,DC=home,DC=local, CN=Organizational-Role,CN=Schema,CN=Configu...
        1 subSchema                 {CN=Aggregate,CN=Schema,CN=Configuration,DC=home,DC=local}
    • This reply was modified 1 year, 9 months ago by  Anthony.
    • #49004

      Jeff Taylor

      Thanks a lot Anthony. Exactly what I was looking for

  • #48791

    Dan Potter
  • #49017

    Jeff Taylor

    Where is my syntax error?

    $varSchema = Get-ADObject -SearchBase ((Get-ADRootDSE).schemaNamingContext) -Filter * -Property *
    $varSchemaObject= Get-ADObject -SearchBase ((Get-ADRootDSE).schemaNamingContext) -Filter {CN -eq “attributeSchema/ms-Exch-Schema-Version-Pt”} -Property *
  • #49034


    The error message was pretty spot on, it had issues with the filter.

    Get-ADObject : Error parsing query: 'CN -eq “attributeSchema/ms-Exch-Schema-Version-Pt”' Error Message: 'syntax error'

    I don't have exchange installed in my lab so I just picked some random CN so I could tell if it was returning something or not.

    $varSchema = Get-ADObject -SearchBase ((Get-ADRootDSE).schemaNamingContext) -Filter * -Property *
    $varSchemaObject = Get-ADObject -Filter 'CN -eq "ms-DS-Claim-Value-Type"' -SearchBase ((Get-ADRootDSE).schemaNamingContext) -Property *
    • #49198

      Jeff Taylor

      Anthony, I switched up the syntax like your example but still get an error"

      Get-ADObject -Filter 'CN -eq “ms-Exch-Schema-Version-Pt”' -SearchBase ((Get-ADRootDSE).schemaNamingContext) -Property *
      Get-ADObject : Error parsing query: 'CN -eq “ms-Exch-Schema-Version-Pt”' Error Message: 'syntax error' at 
      position: '8'.

      Also, tried it with the attribute you had in your lab; same error "at position '8'".

You must be logged in to reply to this topic.