Friday, October 30, 2020

Automate BRE Xml File Import - PowerShell Code

There isn't a lot of information on how to automate a BRE xml file import.  Many suggest using the PowerShell provider that used to be available on Codeplex, but unfortunately it's now a dead page.  There are other resources (QuickLearn) that explain using assemblies in the BizTalk SDK folder.  These have been available since BizTalk 2013.  It appears that what was available in Codeplex has been lifted and shifted to the BizTalk installation process (to the SDK subfolder) on your local server.

This is all good, but there are some limitations.  First, Microsoft doesn't offer any real documentation for the PowerShell SDK.  I had to revert back to a different site to get documentation (version 1.4.0.1, published back in 2014 by Randal van Splunteren and Maxime Labelle) for the PowerShell Provider documentation.

Second, upon looking at this documentation, the BizTalk PowerShell provider doesn't allow for the creation (or importing) of certain artifacts. See screenshot below, highlighted area.


In my case I wanted to automate the deployment of a BRE Policy xml file to the BRE store.  I tested this using the BizTalk SDK assemblies, and the results are the same as the (older) documentation states - function not supported.

So I came across this on the Microsoft website which had a C# snippet of doing what I wanted.  I decided to convert it to PowerShell, since the rest of my processes use PowerShell for builds, releases, and deployments.  I now can now script this out to automate deployments of BRE xml files.  In my case, I use Azure DevOps to perform this using a 'PowerShell on Target Machines' task.

So here's my version of that - use and modify at your own risk.  Enjoy!