Schema script

THIS PAGE IS OBSOLETE - PLEASE VISIT http://psma.codeplex.com for latest version


You can define exactly the schema need for your Management Agent (MA). The schema script is typically dictated by the datasource or system that the scripts communicate with. Therefore, it’s up to the user of this MA to define the schema (and anchor value) by creating a schema definition script.

The MA expects the schema script to return at least one object (PSCustomObject) per object type (object class) that you want to support with the MA. The object returned must include a value for ‘objectClass’ and at least one anchor attribute specified with the prefix ‘Anchor-‘ text, which indicate this to be an anchor attribute (the prefix text will be automatically removed from the attribute name upon schema discovery).

Below is a sample schema script that defines a 'user' object type / object class -

$obj = New-Object -Type PSCustomObject
$obj | Add-Member -Type NoteProperty -Name "Anchor-Id|String" -Value 1
$obj | Add-Member -Type NoteProperty -Name "objectClass|String" -Value "user"
$obj | Add-Member -Type NoteProperty -Name "AccountName|String" -Value "SG"
$obj | Add-Member -Type NoteProperty -Name "FirstName|String" -Value "Soren"
$obj | Add-Member -Type NoteProperty -Name "LastName|String" -Value "Granfeldt"
$obj | Add-Member -Type NoteProperty -Name "DisplayName|String" -Value "Soren Granfeldt"
$obj | Add-Member -Type NoteProperty -Name "Description|String" -Value "Standard User"
$obj | Add-Member -Type NoteProperty -Name "ObjectSID|Binary" -Value 0x10
$obj | Add-Member -Type NoteProperty -Name "DateValue|String" -Value (Get-Date)
$obj | Add-Member -Type NoteProperty -Name "JustABoolean|Boolean" -Value $true
$obj | Add-Member -Type NoteProperty -Name "Manager|Reference" -Value 2
$obj | Add-Member -Type NoteProperty -Name "MemberOf|Reference[]" -Value (2,3)
$obj | Add-Member -Type NoteProperty -Name "MyMultiValue|String[]" -Value ("S1", "S2")
$obj

If the property is an anchor attribute (only one anchor can be specified per object type), it must be prefixed with the case-sensitive text ‘Anchor-‘. An anchor cannot be of type Reference or Boolean.
As can be seen from the sample above, the name of each property of the object returned must be on the form '<name>|<type>', i.e. ‘AccountName|String’. Supported types are -
  • String
  • Integer
  • Boolean
  • Binary
  • Reference
If the property is multivalued, it should be followed by brackets ‘[]’. Please note that only type String and Reference can be multi-valued.

Below you'll find what some may consider a simpler sample version of a schema script -

new-object -typename psobject -prop @{
 "anchor-id|string" = ""
 "objectclass|string" = "user"
 "username|string" = ""
 "userobjectsid|string" = ""
 "userdescription|string" = ""
}

Refreshing the schema

If the schema needs modifications later, you can alter the schema script and perform a ‘Refresh Schema’ on the defined MA.

No comments: