1. Copy the needed files (mdcmd.exe and config.xml) from <Miradore server installation directory>\Connectors\MDCmd to the directory where from you want to use the Command line tool. 2. Set the needed configuration values to config.xml file. This file has to be in same directory as mdcmd.exe. Config.xml should look like the following:
<?xml version="1.0" encoding="UTF-8" ?> <Config> <UserName>domain\username</UserName> <Password>password</Password> <ServerName>server host name</ServerName> <ServerPort>port</ServerPort> <ServerInstance>server instance name</ServerInstance> <UseHttps>https</UseHttps> <UseProxy>use proxy</UseProxy> <ProxyHostName>proxy host</ProxyHostName> <ProxyPort>proxy port</ProxyPort> <ProxyUserName>proxy user</ProxyUserName> <ProxyPassword>proxy password</ProxyPassword> <ProxyAuthMethod>authentication method</ProxyAuthMethod> <VerifyPeer>peer</VerifyPeer> <VerifyHost>host</VerifyHost> <CertFile>cert file</CertFile> <OutputFormat>output format</OutputFormat> <MaxImportCount>import count</MaxImportCount> <LogOnlyErrors>log only errors</LogOnlyErrors> <Separator>separator</Separator> </Config>
Bold text are the configurations that the user has to make and are described below.
|
Miradore command line tool uses the following syntax: mdcmd <command> <object> <parameter list> Where:
Examples mdcmd ? Returns available commands. mdcmd get ? Returns list of available objects which have the 'get' command implemented. mdcmd get hw ? Returns a list of available parameters that can be used to filter results of 'get' command of hardware basic data. mdcmd get hw -hwm lenovo -m "thinkpad t61" Returns all hardware basic data items of which the manufacturer is Lenovo and the model is Thinkpad T61. mdcmd create hwmanufacturer -n "Test Manufacturer" Creates a new hardware manufacturer which name is Test Manufacturer. Notice that also quotes and other special characters can be used with the parameters by using two quotes around the whole parameter and using the special characters inside the string in doubles. See the examples below. mdcmd.exe update assetconfig -dn L0000086 -pw “asd””123” The input value of the password parameter is: asd"123 mdcmd.exe update assetconfig -dn L0000086 -pw “asd\\123” The input value of the password parameter is: asd\123 |
Command line tool’s output is important with get command which is used to get data about CIs. Command line tool prints its output to standard output. This can be redirected using command prompt’s ‘>’ operator. Command line tool supports three different output formats. These formats are database table like, XML and separator separated outputs. Output format is selected in configs.xml (see Initialization above).
Database table like format is human readable format which arranges data easily readable columns and rows.
XML formatted output prints out an XML document which contains all data returned from the server. Format of this XML document is shown below.
Separator separated format prints all data related to one CI on a single line separated by some string. This string can be defined in configs.xml file using the Separator element. Fields are printed in the same order than the columns in the database table like output.
When the output format is set to XML (see Initialization above), the Command line tool prints its output as XML in the following format:
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<!-- Return code from server (0 = server side error, > 0 id of first Item that is processed) -->
<ReturnCode>Return code</ReturnCode>
<!-- Messages from server -->
<Message>
<Line>Message line 1</Line>
<Line>Message line 2</Line>
<Line>Message line N</Line>
</Message>
<!-- Information about processed command -->
<Command>
<!-- Name of target object that was processed -->
<Target name="Target name">
<-- Column names of target object that are read from database (used only with ‘get’ command -->
<Columns>
<Column name="Column 1" />
<Column name="Column 2" />
<Column name="Column N" />
</Columns>
</Target>
<!-- Items that are found with ‘get’ command -->
<ResultItems>
<!-- Information about first found item -->
<Item id="ID1">
<!-- Database columns of first found item -->
<Columns>
<Column name=" Column 1" value="Value of Column 1 of Item ID1" />
<Column name=" Column 2" value="Value of Column 2 of Item ID1" />
<Column name=" Column N" value="Value of Column N of Item ID1" />
</Columns>
</Item>
<!-- Information about second found item -->
<Item id="ID2">
<Columns>
<Column name=" Column 1" value="Value of Column 1 of Item ID2" />
<Column name=" Column 2" value="Value of Column 2 of Item ID2" />
<Column name=" Column N" value="Value of Column N of Item ID2" />
</Columns>
</Item>
<!-- Information about Nth found item -->
<Item id="IDN">
<Columns>
<Column name=" Column 1" value="Value of Column 1 of Item IDN" />
<Column name=" Column 2" value="Value of Column 2 of Item IDN" />
<Column name=" Column N" value="Value of Column N of Item IDN" />
</Columns>
</Item>
</ResultItems>
</Command>
</Response>
Command line tool returns following codes:
Code |
Description |
>0 |
Success, ID of first handled object |
0 |
Server side error |
-1 |
Requested object is not found |
-2 |
Failed to load response xml document |
-3 |
Failed to create request xml document |
-4 |
Failed to read response xml document |
-5 |
Failed to open temporary file |
-6 |
Failed to read temporary file |
-7 |
Server name not found from configurations file. |
-8 |
Server instance not found from configurations file |
-9 |
Failed to initialize http connection |
-10 |
Configurations file (config.xml) not found. |
-11 |
Failed to send http request to server. |
-12 |
Failed to write SSL root certificate file (cacert.pem) |