Author Posts

July 29, 2016 at 10:02 pm

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

July 30, 2016 at 4:04 am

$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 years ago by  Anthony.

August 1, 2016 at 8:23 pm

Thanks a lot Anthony. Exactly what I was looking for

August 1, 2016 at 10:11 pm

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 *

August 2, 2016 at 2:14 am

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 *

August 3, 2016 at 11:25 pm

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