Originally posted at: MIM 2016: RCDC Management with PowerShell @ IS4U Blog
Introduction
Editing the xml configuration of an RCDC can be time consuming if you have a lot of custom objects and or attributes in the portal schema. This article describes a way to automate this task completely. It also provides a start in implementing this approach in powershell using the System.Xml.Linq library.
Creating a new rcdc
If you create a new object type in the portal schema, you want the end users to have a nice rcdc instead of the default interface. The portal offers you the ability to download a template file that you can then edit. If you strip this template file further, only retaining fields for display name and description, it is possible to reuse this as a starting point for all future rcdc’s by editing the caption. A function could read such a local copy of the stripped down template, edit the caption and return the result.
Implementation: Get-DefaultRcdc
.
The creation of a new rcdc requires following parameters:
- Display Name
- Target Object Type
- XML Configuration Data
- One of the following:
- Applies to Create
- Applies to Edit
- Applies to View
Implementation: New-Rcdc
.
Example:
$departmentRcdc = Get-DefaultRcdc -Caption "Create Department" -Create New-Rcdc -DisplayName "Configuration for Department Creation" -ObjectType "Department" -ConfigurationData $departmentRcdc -AppliesToCreate
Updating an existing rcdc
Updating the rcdc is a little bit more complex. Controls need to be constructed. A separate function for each type of control can be defined.
Implementation:
Example:
$textbox = Get-RcdcTextBox -AttributeName VisaCardNumber $textbox.ToString()
<Control p1:Name="VisaCardNumber" p1:TypeName="UocTextBox" p1:Caption="{Binding Source=schema, Path=VisaCardNumber.DisplayName}" p1:Description="{Binding Source=schema, Path=VisaCardNumber.Description}" p1:RightsLevel="{Binding Source=rights, Path=VisaCardNumber}" xmlns:p1="http://schemas.microsoft.com/2006/11/ResourceManagement" xmlns="http://schemas.microsoft.com/2006/11/ResourceManagement"> <p1:Properties> <p1:Property p1:Name="ReadOnly" p1:Value="false" /> <p1:Property p1:Name="Required" p1:Value="{Binding Source=schema, Path=VisaCardNumber.Required}" /> <p1:Property p1:Name="Text" p1:Value="{Binding Source=object, Path=VisaCardNumber, Mode=TwoWay}" /> <p1:Property p1:Name="MaxLength" p1:Value="400" /> <p1:Property p1:Name="RegularExpression" p1:Value="{Binding Source=schema, Path=VisaCardNumber.StringRegex}" /> <p1:Property p1:Name="Hint" p1:Value="{Binding Source=schema, Path=VisaCardNumber.Hint}" /> </p1:Properties> </Control>
After generating the xml configuration for a control it needs to be inserted into an existing xml structure. The function that is responsible for this step requires at least following inputs:
- Display name of the rcdc.
- Name of the grouping where the control needs to be inserted. If the grouping does not exist, a new one will be created.
- Xml configuration for the new control.
- Optional: Caption for the grouping if it does not yet exist.
Implementation: Add-ElementToRcdc
.
Example:
Add-ElementToRcdc -DisplayName "Configuration for User Editing" -GroupingName "BasicInfo" -RcdcElement $textbox
Validating the rcdc
Validation steps can be added before uploading xml configuration data, preventing lots of frustrated hours of searching for that one typo. Validation can also be done against manually edited rcdc configuration files and uses a local copy of the xsd schema file from technet.
Implementation: Test-RcdcConfiguration
.
Todo
A lot of work remains. An inverse function for Add-ElementToRcdc
, Remove-ElementFromRcdc
needs to be implemented. Also, functions to generate other types of rcdc controls are lacking. Anyone can contribute! If you feel like writing a function or two, just go at it and send a pull request on the github project.