Basic irCatalog Management Using Powershell


Josh Elster


Hand-modification of a web.config file is one of the more common post-installation tasks that our customers find themselves performing. Similarly, because I am always setting up and tearing down new environments and servers, I find myself repeatedly needing to perform some common tasks.

The typical use case for this script is when a catalog database has been replaced or restored to a different server, necessitating an administrator update to the connection string under the inrule.repository.service configuration node.

Because I’m a lazy developer, I decided to write a script to avoid the repetition. Since I’m also prone to mix up or miss steps and typo config entries, making the steps involved in configuring a new environment reliably repeatable is a huge benefit as well.

The script (see below for full text), Set-CatalogConfig.ps1, will use the provided parameters to construct a connection string for the given catalog database on the given database host. Then, it loads the repository service’s web.config (defaults to the same as the default installation path) and navigates down to the inrule.repository.service.connectionString node before setting the value to the constructed connection string and saving the updated config.

You may wonder why I’m going to the trouble of loading the XML and navigating it via the XML object model. The reason is that having the object loaded makes it trivial to add additional configuration settings management abilities.

Note: the ‘ around the names of the InRule custom configuration sections escapes what wouldn’t otherwise be treated as a single node.

This script does only a little bit of error checking and uses some hard-coded values – Your Mileage May Vary. The script demonstrates support for the WhatIf flag as well as writing additional messages when the -Verbose flag is provided to aid in troubleshooting and less risky experimentation.

In my next post on this topic, I’ll talk about a script that creates the database and schema for irCatalog. In the meantime, I hope you find this useful!

InRule for JavaScript | inrule said: "[…] couple of weeks ago we announced availability of InRule® for JavaScript through an early adopter program. To our knowledge this is […]".
Dynamic Surveys in Dynamics CRM Part II: Managing Dependencies | inrule said: "[…] this post makes extensive references to my preceding post, Surveys in Dynamics CRM Part I: Don’t Be a Monkey With Your Survey. If you are the type of person who likes to get the full story, you should go back and read the […]".
Josh Elster said: "In the time since this post was published, I've added (via a PR) full Windows Containers example code, DOCKERFILEs and scripts. They share common ancestry with the GH Gists I posted earlier, but are more up-to-date and tested. Here's a direct link to that sub-folder: Now that our Samples repository is public, feel free to file Issues if you have problems or features you'd like to see implemented. If you have something you'd like to contribute, then by all means do so! The contributor guidelines and process are listed in the root of the repository. Enjoy! I'll update the body of the post as well with this link.".