Adapter request and response for the PowerShell adapter
The PowerShell actor adapter sends commands to PowerShell and receives responses and results from the CLI of PowerShell. The PowerShell actor adapter works with PowerShell 1.0 and 2.0.
To configure an adapter request to communicate with the host computer that is not defined in the adapter configuration, you can designate a dynamic target by assigning values for the required configuration elements. These elements work as a set. You cannot retrieve partial information from the configuration node.
You can omit the <targets> block from the adapter request. In the absence of a <targets> block, the default target from the adapter configuration is used.
To override the configuration properties in the adapter configuration, include the target, user name, and password elements in the request. The following table describes the elements of the PowerShell adapter request.
Elements of the PowerShell adapter request
The following figure shows an XML sample for the PowerShell actor adapter request.
XML sample of the PowerShell adapter request
<targets>
<target>
<host></host>
<user-name></user-name>
<password encryption-type="">testpass</password>
<character-set>gb18030</character-set>
<powershell-version>1.0</powershell-version>
<powershell-consolefile>pshell.psc1</powershell-consolefile>
<use-userprofile>true</use-userprofile>
</target>
</targets>
<commands>
<command></command>
<command></command>
</commands>
</powershell-request>
The following figure shows the adapter request for the PowerShell adapter, where multiple PowerShell commands are used in a single adapter request. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio.
XML sample of the PowerShell adapter request
<commands>
<command>get-alert -criteria {Name LIKE 'Performance%' }</command>
<command>get-service</command>
</commands>
</powershell-request>
The following figure shows an example of the Powershell adapter request with the get-service PowerShell command.
XML sample of the PowerShell adapter request with get-service command
<targets>
<target>
<host>computer2</host>
<user-name>testuser</user-name>
<password encryption-type="Plain">testpass</password>
<character-set>gb18030</character-set>
<powershell-version>1.0</powershell-version>
<powershell-consolefile>pshell.psc1</powershell-consolefile>
<use-userprofile>true</use-userprofile>
</target>
</targets>
<commands>
<command>get-service</command>
</commands>
</powershell-request>
The following figure shows an XML sample for the PowerShell adapter request with relative path. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio.
XML sample of the PowerShell adapter request with relative path
<commands>
<command working-dir=" D:\scripts">./SampleScript.ps1</command>
<command working-dir=" D:\scripts">./OSProperties.ps1</command>
</commands>
</powershell-request>
The following figure shows an XML sample for the PowerShell adapter request with full path. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio.
XML sample of the PowerShell adapter request with full path
<commands>
<command>D:\scripts\SampleScript.ps1</command>
<command>D:\scripts\OSProperties.ps1</command>
</commands>
</powershell-request>
The following figure shows an XML sample for the PowerShell actor adapter request when the remoting feature is enabled.
XML sample of the PowerShell adapter request when the remoting feature is enabled
<targets>
<target>
<host>10.128.249.47</host>
<user-name>bmcadmin</user-name>
<password encryption-type="Plain">Global@123</password>
<powershell-version>2.0</powershell-version>
<enable-psremoting>true</enable-psremoting>
</target>
</targets>
<commands>
<command>ipconfig</command>
.
.
.
</commands>
</powershell-request>
The following figure shows an XML sample for the PowerShell actor adapter request when <logon-with-user-credentials> is set to true.
XML sample of the PowerShell adapter request when <logon-with-user-credentials> is set to true
<targets>
<target>
<host>BMC-GLOBALLOGIC</host>
<user-name>bmcadmin</user-name>
<password>bmc123</password>
<powershell-version>1.0</powershell-version>
<logon-with-user-credentials>true</logon-with-user-credentials>
</target>
</targets>
<commands>
<command>ipconfig</command>
</commands>
</powershell-request>
The PowerShell adapter response contains the result returned from an adapter request. The following figure shows an XML sample for the PowerShell adapter response with get-service PowerShell command.
XML sample of the PowerShell adapter response
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output host = "10.128.248.76">
<metadata>
<os-id>Windows 2003</os-id>
<os-version>5.2 Build 3790 Service Pack 2</os-version>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>Get-Service</command>
<line-count>170</line-count>
<execution-milliseconds>7735</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index = "1">Copyright 2010 BMC Software Ltd, Version: 1.1</line>
<line index = "2">Connecting to remote service...</line>
<line index = "3">Connected to remote host.</line>
<line index = "4">Status Name DisplayName</line>
<line index = "5">------ ---- -----------</line>
*** command response ***
<line index = "169">Stopped xmlprov Network Provisioning Service</line>
<line index = "170">Remote application exited with code: 0</line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</powershell-output>
The following figure shows an XML sample for the PowerShell adapter response when the remoting feature is enabled in the adapter request.
XML sample of the PowerShell adapter response when the remoting feature is enabled
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output host="10.128.249.47">
<metadata>
<os-id>Windows XP</os-id>
<os-version>5.1.2600</os-version>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>ipconfig</command>
<line-count>11</line-count>
<execution-milliseconds>1492</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">Windows IP Configuration</line>
<line index="2">Ethernet adapter Local Area Connection:</line>
<line index="3"> Connection-specific DNS Suffix . : bmc.com</line>
<line index="4"> IP Address. . . . . . . . . . . . : 10.128.249.47</line>
<line index="5"> Subnet Mask . . . . . . . . . . . : 255.255.254.0</line>
<line index="6"> Default Gateway . . . . . . . . . : 10.128.248.1</line>
<line index="7">Ethernet adapter...........:</line>
<line index="8"> Connection-specific DNS Suffix . : </line>
<line index="9"> IP Address. . . . . . . . . . . . : 0.0.0.0</line>
<line index="10"> Subnet Mask . . . . . . . . . . . : 0.0.0.0</line>
<line index="11"> Default Gateway . . . . . . . . . : </line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</powershell-output>
The following figure shows an XML sample for the PowerShell actor adapter response when <logon-with-user-credentials> is set to true.
XML sample of the PowerShell adapter response when <logon-with-user-credentials> is set to true
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output host="10.128.249.47">
<metadata>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>ipconfig</command>
<line-count>15</line-count>
<execution-milliseconds>32938</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">Copyright 2010 BMC Software Ltd, Version: 1.5 </line>
<line index="2">Connecting to remote service...</line>
<line index="3">Connected to remote host.</line>
<line index="4">Windows IP Configuration</line>
<line index="5">Ethernet adapter Local Area Connection:</line>
<line index="6"> Connection-specific DNS Suffix . : bmc.com</line>
<line index="7"> IP Address. . . . . . . . . . . . : 10.128.249.47</line>
<line index="8"> Subnet Mask . . . . . . . . . . . : 255.255.254.0</line>
<line index="9"> Default Gateway . . . . . . . . . : 10.128.248.1</line>
<line index="10">Ethernet adapter {EDE30461-C964-4723-863B-AD7D4CFE4886}:</line>
<line index="11"> Connection-specific DNS Suffix . : </line>
<line index="12"> IP Address. . . . . . . . . . . . : 0.0.0.0</line>
<line index="13"> Subnet Mask . . . . . . . . . . . : 0.0.0.0</line>
<line index="14"> Default Gateway . . . . . . . . . : </line>
<line index="15">Remote application exited with code: 0 </line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</powershell-output>
The following figure shows an XML sample for the PowerShell actor adapter request when the <impersonate-user> is set to true.
XML sample for the PowerShell actor adapter request when the <impersonate-user> is set to true
<targets>
<target>
<host>vm-w23-rds87</host>
<userName>Domain_Name\User</userName>
<password encryption-type="Plain">XXXXXXX</password>
<impersonate-user>true</impersonate-user>
<logon-with-user-credentials />
<service-launch-mode />
<character-set />
<powershell-version>1.0</powershell-version>
</target>
</targets>
<commands>
<command>get-service</command>
</commands>
</powershell-request>
The following figure shows an XML sample for the PowerShell actor adapter request when the <service-launch-mode> is 64-bit.
XML sample for the PowerShell actor adapter request when the <service-launch-mode> is 64-bit
<targets>
<target>
<host>vm-w23-rds87</host>
<userName>Domain_Name\User</userName>
<password encryption-type="Plain">XXXXXXX</password>
<impersonate-user>true</impersonate-user>
<logon-with-user-credentials />
<service-launch-mode>64bit</service-launch-mode>
<character-set />
<powershell-version>1.0</powershell-version>
</target>
</targets>
<commands>
<command timeout-secs="150">whoami</command>
</commands>
</powershell-request>