UCSD: Passing multiple arguments to start-job while using the Cisco PowerShell Agent

While the¬†Cisco PowerShell Agent (PSA) that can be used in UCS Director isn’t exactly perfect, it can still be put to good use. As long as you now how to use it properly Smilie: ;)

The major issue with using the PSA is that it doesn’t stick around to see if the commands/script was successful or not. As long as it delivered the commands successfully, it’s happy and your workflow will continue to the next step.

Jon Hildebrand describes a nice way around this in one of his blog posts: http://snoopj.wordpress.com/2014/11/05/cisco-powershell-agent-service-and-vmware-vum-powercli/

Using his approach, I was able get the PSA to stick around until the job finishes. However, I ran into a challenge when I wanted to pass multiple arguments to start-job. The solution I came up with was declaring the UCSD inputs I wanted to use as powershell variables in the script, before calling the start-job cmdlet. So the commands/script input looks like this:

$vm = "${custom_getVMDetails_7494.vmName}"
$annotation = "${Annotation}"
$annotationvalue = "${AnnotationValue}"
Start-Job -FilePath "C:\Powershell\Annotate-VM.ps1" -ArgumentList $vm,$annotation,$annotationvalue | Wait-Job

In case you are wondering, this task is for setting annotations on a vm in vCenter.
The powershell script I am calling is pretty simple:

Param (
Add-PSSnapin vmware*
Set-Annotation -Entity $VM -CustomAttribute "$($Annotation)" -Value "$($AnnotationValue)"
Disconnect-VIServer  -Confirm:$false
Category(s): Cisco, UCS Director
Tags: , , , ,

4 Responses to UCSD: Passing multiple arguments to start-job while using the Cisco PowerShell Agent

  1. Great post thanks! I have managed to get this working (well mostly!). I have been trying to integrate UCSD with System Center Orchestrator and ended up doing this through the PSA as I know Powershell better than REST and couldn’t get my head around the Orchestrator Web Service!

    I’ve got the PSA to be able to send Parameters through to SCORCH now which is fantastic, the bit i can’t work out though is how to pass variables back to UCSD from the PSA so that they can be used further down the UCSD workflow. Do you know if there is a way of getting the variables back from the Start-Job and back into UCSD?

    Again, massive thanks, really helped !!!


    • Glad it helped you along the way Smilie: :)

      So far, I have worked my way around getting variables back to UCSD from PSA. I know that the powershell task does have an output if you use it in a workflow, but I haven’t looked at how to use it further down. If I someday do, I’ll write a post about it

  2. How do you get the cool background to the powershell window? I guess that isn’t the standard powershell command window?

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.