cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2015
Views
0
Helpful
4
Replies
Paul O'Leary
Beginner

Powershell Task - Error in Workflow

Trying to execute a task inside a workflow. The task is a powershell call that tries to use the VMware Provision Inputs value of vmNameorPrefix as the basis for creating an AD object with the simple powershell script command new-adcomputer.

The script is functional on the Agent when run manually, but I seem to be unable to either parse the ${vmNameorPrefix} variable from the workflow properly or something else is awry.

Any help will be appreciated as the docco is vague on how exactly to use values within the workflow.

May 22, 2015 06:01:29 EST Task: Basic VM Deployment (Execute PowerShell Command) failed with error - Command faileError while executing command: java.lang.Exception: Error code: 3, error message: Exception while executing script, selectedContext=<None>

May 22, 2015 06:01:29 EST Task #4 (Basic VM Deployment (Execute PowerShell Command)) failed after 1 seconds

May 22, 2015 06:01:29 EST Input/Output values for Task #4 (Basic VM Deployment (Execute PowerShell Command)):

May 22, 2015 06:01:29 EST [Local Input: Label = Make AD Object]

May 22, 2015 06:01:29 EST [Local Input: PowerShell Agent = 192.168.0.2]

May 22, 2015 06:01:29 EST [Local Input: Target Machine IP = 192.168.0.2]

May 22, 2015 06:01:29 EST [Local Input: User ID = ADUSER]

May 22, 2015 06:01:29 EST [Local Input: Password = **masked-value**]

May 22, 2015 06:01:29 EST [Local Input: Domain = TEST]

May 22, 2015 06:01:29 EST [Template Input:Commands/Script = $vm = '${vmNameorPrefix}' Start-Job -FilePath C:\\Source\\Scripts\\ADD_AD_Computer.ps1 -ArgumentList \$vm |Wait-Job |Receive-Job]

May 22, 2015 06:01:29 EST [Resolved Template Input: Commands/Script = = '' Start-Job -FilePath C:\Source\Scripts\ADD_AD_Computer.ps1 -ArgumentList $vm |Wait-Job |Receive-Job]

May 22, 2015 06:01:29 EST [Local Input: Commands/Script = = '' Start-Job -FilePath C:\Source\Scripts\ADD_AD_Computer.ps1 -ArgumentList $vm |Wait-Job |Receive-Job]

May 22, 2015 06:01:29 EST [Local Input: Maximum Wait Time = 5]

May 22, 2015 06:01:29 EST Completed workflow item number 5, with status Failed

May 22, 2015 06:01:29 EST Task: Basic VM Deployment (Execute PowerShell Command) failed with error - Command faileError while executing command: java.lang.Exception: Error code: 3, error message: Exception while executing script, selectedContext=<None>

1 ACCEPTED SOLUTION

Accepted Solutions

Ah, just found my answer!

UCS Director workflow variables

https://communities.cisco.com/thread/47740

Any variable in UCSD can be called using the ${<variable name>} format. So if your hostname input is labelled "host_name", then you can use or call the value provided by the end user by calling ${host_name}.

View solution in original post

4 REPLIES 4
snoopj123
Enthusiast

I've used Start-Job before, but this is the syntax I'm using:

Start-Job -FilePath "C:\\Powershell\\VMware_InstallNexus1000v.ps1" -PSVersion 2.0 -ArgumentList "${GetResolvedIPAddressFromIPPoolTask_772.IPAddress}" | Wait-Job

That's exactly how I have it crafted in the Commands/Script box.  I remember having to put the path to the PS1 file in double quotes and putting the variable arguments in double quotes as well.  Maybe those nuggets will help.

Yeah, I think the problem is getting the arguments right from the user input mapping. I don't know how to reference the workflow User Input from within itself. You're calling a different task to provide a result. I've tried the full reference like:

"${VMWareProvisionInputs_214.vmNameorPrefix}"

But that is always blank.

Ah, just found my answer!

UCS Director workflow variables

https://communities.cisco.com/thread/47740

Any variable in UCSD can be called using the ${<variable name>} format. So if your hostname input is labelled "host_name", then you can use or call the value provided by the end user by calling ${host_name}.

View solution in original post

Excellent to hear you resolved the issue!

Content for Community-Ad
This widget could not be displayed.