Monday, 31 October 2016

MIM 2016: RCDC Management with PowerShell

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
Creation of a new rcdc for the custom object Department could look like this:
$departmentRcdc = Get-DefaultRcdc -Caption "Create Department" -Create
New-Rcdc -DisplayName "Configuration for Department Creation" 
  -ObjectType "Department" -ConfigurationData $departmentRcdc -AppliesToCreate

Implementation: New-Rcdc.

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:

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.

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.

References

No comments: