I am using Run Command in Guest to execute the below commands on a windows host. The account running the command has authorizations to run these command.
cmd.exe /c dnscmd xx.xx.xx.xx /recorddelete some.dns.host hostName1 A xx.xx.xx.xx /f
cmd.exe /c dnscmd xx.xx.xx.xx /recorddelete some.dns.host hostname1 PTR /f
(actual IP info and hostnames are concealed to protect the innocent)
Both run successfully (and as intended) if run interactively from a CMD prompt, I get the expected result and a nslookup on the hostname indicates '...can't find <hostname>: Non-existend domain' as expected. (img1 attached)
If run via the Run Command in Guest, the first command executes (to remove the A record, however, while the second command seems to run, the PTR record isn't removed and nslookup on the hostname returns 'Name: <hostname>" (img2 attached)
Thoughts?
Here's a snippet of "command" object processing from one of the articles on my blog: How to run a PERL Script from a vCenter Orchestrator Workflow
// Prepare Command line and parameters to execute:
cmd = scriptName + " " + scriptParams;
System.debug("executing cmd: " + cmd);
// Create and execute the command:
var command = new Command(cmd);
command.execute(true);
// Display command results and output
var scriptResult = command.result;
System.debug("Script Result: " + scriptResult);
var scriptOutput = command.output;
System.debug("Script Output: " + scriptOutput);
As you can see from the above code, you'll want to take a look at the results and output of your cmd object's execution. Hopefully that output will contain some clue as to why your second command is failing...
Does the account that you are logging in with on your workflow have access to change DNS records?
I am advised the service account associated with running the vCO flows has full permissions to change DNS records. Do note the first command to delete the A record does execute successfully via the same vCO flow.
I assume you are using Command object to execute this right? From execute are you getting 0 and an result from output on both? Maybe put a sleep in between both running commands? I don't usually use this object, for my AD/DNS operations in Orchestrator I use the PowerShell plug-in.
Okay, Run Command In Guest implies that you are running Guest Operations so this is not using the "command" object to run these commands locally on the vCO host, right?
These two commands... are you attempting to run them with a single call to the remote machine or two sequential calls? I've only attempted single calls. Have you tried putting a short delay between the two calls?
If the first command is running, that does seem to indicate that the credentials being used are sufficient. You might want to try piping the output of your command into a log text file to see what is happening...
Something along the lines of:
cmd.exe /c dnscmd xx.xx.xx.xx /recorddelete some.dns.host hostname1 PTR /f >> c:\dnscmndResults.txt
OK... my mistake. I mis-recalled how I was doing this. Just checked the flow... I'm doing this within scriptable task with the below code. Each of the values within the first two lines are attributes from the flow.
var cmd0 = "cmd.exe /c dnscmd" + " " + hostDNS + " " + recordRemoveCmd + " " + zoneName + " " + nodeName + " " + typeA + " " + vmIP + " /f";
var cmd1 = "cmd.exe /c dnscmd" + " " + hostDNS + " " + recordRemoveCmd + " " + zoneName + " " + nodeName + " " + typePTR + " /f";
var command0 = new Command(cmd0);
var command1 = new Command(cmd1);
command0.execute (true);
System.sleep(10000);
command1.execute (true);
System.sleep(10000);
Server.log(cmd0);
System.log(cmd0);
Server.log(cmd1);
System.log(cmd1);
Check the return value from the execute method. It should be 0 for both commands, non-zero is an error.
Here's a snippet of "command" object processing from one of the articles on my blog: How to run a PERL Script from a vCenter Orchestrator Workflow
// Prepare Command line and parameters to execute:
cmd = scriptName + " " + scriptParams;
System.debug("executing cmd: " + cmd);
// Create and execute the command:
var command = new Command(cmd);
command.execute(true);
// Display command results and output
var scriptResult = command.result;
System.debug("Script Result: " + scriptResult);
var scriptOutput = command.output;
System.debug("Script Output: " + scriptOutput);
As you can see from the above code, you'll want to take a look at the results and output of your cmd object's execution. Hopefully that output will contain some clue as to why your second command is failing...