How to get count of all schema attributes/classes

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()


$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}

Looks familiar.

Thanks a lot Anthony. Exactly what I was looking for

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 *

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 *

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’”.