How to get count of all schema attributes/classes

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Jeff Taylor Jeff Taylor 1 month, 4 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #48762
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

    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
    Profile photo of Anthony
    Anthony
    Participant
    $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 2 months ago by Profile photo of Anthony Anthony.
    #48791
    Profile photo of Dan Potter
    Dan Potter
    Participant
    #49004
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

    Thanks a lot Anthony. Exactly what I was looking for

    #49017
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

    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
    Profile photo of Anthony
    Anthony
    Participant

    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
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

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

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.