Powershell

0

Wanted: Tester for Preview of my PowerSSHell-Plugin for vCO

I’m looking for Tester for my first Plugin for the Orchestrator: The PowerSSHell-Plugin for vCO

It allows you to execute Powershell Cmdlets and -Scripts from within workflows, without struggle with Security Context or painful parsing output text-data because it leverages the PowerShell SSH Server of powershell|inside and provides object-oriented results.

PowerSSHell-Plugin for Orchestrator - Architecture

So please Download the Plugin (it’s free, yet 😎 :-D), give it a try and share your comments on http://getsatisfaction.com/vcoportal

I’m looking forward to your feedback to create a further roadmap for the Plugin!

0

updated: Calling vCO-Workflows from Powershell

It was long on the TODO-list, now I got an reason (http://communities.vmware.com/thread/316038?tstart=0):
Extending the Powershell-script that calls vCO-workflows with input and output-parameters.

When executing the workflow, you have to specify an array of WorkflowtokenAttribute-Objects, which can be created in the namespace of the Webservice-Proxy:


# Connect to vCO and generate Proxy $vcoWS (-Class and -Namespace for easy stub-object generation later
 $vcoWS = New-WebServiceProxy -Class VCO -Namespace VCO -Uri http://192.168.215.176:8280/vmware-vmo-webcontrol/webservice?WSDL
 ...

# generate Array with Input PArameters (WorkflowTokenAttribute - Objects)
 $inparams = @()

# fill the array, one entry for each input parameter
 $inparams += New-Object -TypeName VCO.WorkflowTokenAttribute
 $inparams[0].name = "inputString"
 $inparams[0].type = "String"
 $inparams[0].value = "Hello World"

# ... and exectue (use $null instead on $inparams if Workflow has no input parameters
 $workflowToken = $vcoWS.executeWorkflow($workflow.id, "vcoadmin1" , "VMware2010", $inparams)

...

A comparable array of WorkflowTokenAttribute-Objects which contains the Output-Parameters of the workflow can be returned by


# get Output-Parameter, when workflow has finished #($wftResults is again an array of WorkflowTokenAttribute
$wftResults = $vcoWS.getWorkflowTokenResult($workflowToken.id, "vcoadmin1", "VMware2010")
$wftResults

the missing link: How to create Stub-Objects from scratch…
the hint: http://stackoverflow.com/questions/4196523/render-ssrs-report-with-parameters-using-soap-in-powershell

See the full updated example here:
http://www.vcoportal.de/examples/powershell-vco/

0

PowerShell & vCO – Call Orchestrator Workflows from PowerShell

UPDATE 6. January 2012:
For an example how to provide inventory objects as input parameters, see this post:
http://www.vcoportal.de/2012/01/how-to-find-inventory-objects-when-calling-vco-workflows-via-the-soap-api/

Execute vCO-Workflow with Powershell:
Via the WebService-API you can execute vCO-workflows automatically. And Powershell 2.0 has a built-in Client for WebServices. So it’s straight forward to start an workflow within a Powershell-Skript:


# Connect to vCO and generate Proxy $vcoWS (-Class and -Namespace for easy stub-object generation later
 # Verbindung zum vCO herstellen und Proxy $vcoWS generieren
 $vcoWS = New-WebServiceProxy -Class VCO -Namespace VCO -Uri http://192.168.215.176:8280/vmware-vmo-webcontrol/webservice?WSDL

# print out result (in every ...)
 # Ergebnis ausgeben (in jedem Schritt...)
 $vcoWS

# Get all Methods of the webserviceProxy
 $vcoWS|get-member|where { $_.MemberType -eq "Method" }

# Find Workflows with name "demoWorkflowWithStringInput" (returns an array!)
 # Workflows mit dem Namen "demoWorkflowWithStringInput" finden (gibt ein Array zurück)
 $workflows = $vcoWS.getWorkflowsWithName("demoWorkflowWithStringInput", "vcoadmin1" , "VMware2010")
 $workflows

# pop first Workflow from resulting array
 # ersten Workflow aus dem Ergebnisarray holen...
 $workflow = $workflows[0]
 $workflow

# print out input Parameters
 $workflow.inParameters

# generate Array with Input PArameters (WorkflowTokenAttribute - Objects)
 $inparams = @()

# fill the array, one entry for each input parameter
 $inparams += New-Object -TypeName VCO.WorkflowTokenAttribute
 $inparams[0].name = "inputString"
 $inparams[0].type = "String"
 $inparams[0].value = "Hello World"

$inparams

# ... and exectue (use $null instead on $inparams if Workflow has no input parameters
 # ... und ausführen
 $workflowToken = $vcoWS.executeWorkflow($workflow.id, "vcoadmin1" , "VMware2010", $inparams)
 $workflowToken

# monitor execution state of Workflow-Token
 # Status der Ausführung überwachen
 do { Start-Sleep -Seconds 2 }
 while ( $vcoWS.getWorkflowTokenStatus(@($workflowToken.id), "vcoadmin1" , "VMware2010") -eq"running")

# get Output-Parameter, when workflow has finished
 #($wftResults is again an array of WorkflowTokenAttribute
 $wftResults = $vcoWS.getWorkflowTokenResult($workflowToken.id, "vcoadmin1", "VMware2010")
 $wftResults

To define input parameters for the workflow, you have to create an array of WorkflowTokenAttribute-Object, each of them with a name, type and value-parameter. (Therefore the -Class and -Namespace parameters when creating the WebService-Proxy)

The output returned from getWorkflowTokenResult are also an array of WorkflowTokenAttrinbute-Objects.

This examples calls a small workflow which just copy an input-string to an output-parameter:

More information about creating a WebService-Client for vCO is in the developer guide:
http://www.vmware.com/pdf/vco_410_developers_guide.pdf#page=245
More information about the New-WebServiceProxy-CmdLet:
http://technet.microsoft.com/en-us/library/dd315258.aspx

# Connect to vCO and generate Proxy $vcoWS (-Class and -Namespace for easy stub-object generation later
# Verbindung zum vCO herstellen und Proxy $vcoWS generieren
$vcoWS = New-WebServiceProxy -Class VCO -Namespace VCO -Uri http://192.168.215.176:8280/vmware-vmo-webcontrol/webservice?WSDL# print out result (in every …)
# Ergebnis ausgeben (in jedem Schritt…)
$vcoWS# Get all Methods of the webserviceProxy
$vcoWS|get-member|where { $_.MemberType -eq “Method” }

# Find Workflows with name “demoWorkflowWithStringInput” (returns an array!)
# Workflows mit dem Namen “demoWorkflowWithStringInput” finden (gibt ein Array zurück)
$workflows = $vcoWS.getWorkflowsWithName(“demoWorkflowWithStringInput”, “vcoadmin1” , “VMware2010”)
$workflows

# pop first Workflow from resulting array
# ersten Workflow aus dem Ergebnisarray holen…
$workflow = $workflows[0]
$workflow

# print out input Parameters
$workflow.inParameters

# generate Array with Input PArameters (WorkflowTokenAttribute – Objects)
$inparams = @()

# fill the array, one entry for each input parameter
$inparams += New-Object -TypeName VCO.WorkflowTokenAttribute
$inparams[0].name = “inputString”
$inparams[0].type = “String”
$inparams[0].value = “Hello World”

$inparams

# … and exectue (use $null instead on $inparams if Workflow has no input parameters
# … und ausführen
$workflowToken = $vcoWS.executeWorkflow($workflow.id, “vcoadmin1” , “VMware2010”, $inparams)
$workflowToken

# monitor execution state of Workflow-Token
# Status der Ausführung überwachen
do { Start-Sleep -Seconds 2 }
while ( $vcoWS.getWorkflowTokenStatus(@($workflowToken.id), “vcoadmin1” , “VMware2010″) -eq”running”)

# get Output-Parameter, when workflow has finished
#($wftResults is again an array of WorkflowTokenAttribute
$wftResults = $vcoWS.getWorkflowTokenResult($workflowToken.id, “vcoadmin1”, “VMware2010”)
$wftResults

0

vCO & PowerShell – Call Powershell-scripts from vCO

Execute Powershell from vCO:

var arg1 = "firstArgument";
 var arg2 = "secondArgument";
 var cmd = "cmd.exe /c powershell.exe " +
 " -Command \". 'c:\\vcoScripts\\somePowershellScript.ps1' '"
 + arg1+ "' '" + arg2 + "' \""
 + " < NUL 2>&1"
 //optional logging + " >>c:/vcoScripts/powershell.log 2>&1"
 ;
 var command = new Command(cmd);
 command.execute(true);

More information:
http://wannemacher.us/?p=346
http://communities.vmware.com/thread/271425