How to get count of all schema attributes/classes

Welcome Forums General PowerShell Q&A How to get count of all schema attributes/classes

This topic contains 6 replies, has 3 voices, and was last updated by

 
Participant
2 years, 3 months ago.

  • Author
    Posts
  • #48762

    Participant
    Points: 58
    Rank: Member

    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()
    $schema.FindClass("attributeSchema")

    Thanks

  • #48768

    Participant
    Points: 0
    Rank: Member
    $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}
    • #49004

      Participant
      Points: 58
      Rank: Member

      Thanks a lot Anthony. Exactly what I was looking for

  • #48791

    Participant
    Points: 21
    Rank: Member
  • #49017

    Participant
    Points: 58
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

      Participant
      Points: 58
      Rank: Member

      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'".

The topic ‘How to get count of all schema attributes/classes’ is closed to new replies.