Invoking Mirth Connect CLI with Powershell script

走远了吗. 提交于 2020-02-03 23:48:12

问题


I'm using powershell 4 to invoke the Mirth Connect command line interface (mccommand.exe). I am explicitly avoiding use of the "-s" parameter of the Mirth CLI to pass a Mirth script file because I want to pass dynamic commands instead to the Mirth Shell.

When I invoke mccommand.exe from an interactive powershell console, I am able to connect to the Mirth Connect server and the Mirth Shell is opened where I can run one or more Mirth Shell commands to manage Mirth Channels.

Example:

. "C:\Program Files (x86)\Mirth Connect\mccommand.exe" -a "https://localhost:8443" -u admin_user -p admin_password
Connected to Mirth Connect server @ https://localhost:8443 (3.4.1.8057)
$

When I run the same command from within a powershell script via the Windows Powershell ISE, I get the same "Connected to Mirth Connect server @ https://localhost:8443 (3.4.1.8057)" message but the script waits and I never get the "$" command prompt that allows me to pass Mirth Shell commands to Mirth.

Any thoughts on how I can route commands to the Mirth Shell via a Powershell script?


回答1:


So you have to pass all the mirth shell commands as text file. This is what I use to import and deploy any channel.

Follow the below code:

Set-Location 'C:\Mirth Connect'
$ChannelOutput=.\mccommand.exe -a https://localhost:38443 -u username -p password -s "C:\commands.txt"

If($ChannelOutput -like '*successfully*')
{
"Channel created successfully and deplyed"
}
else
{
$_.Exception.Message
}

The Text file should have the set of commands like the below:

Commands.txt: 
 import "C:\TestServiceChannel1.xml" Force
channel deploy "Channel_name"


来源:https://stackoverflow.com/questions/38400543/invoking-mirth-connect-cli-with-powershell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!