06-20-2014 11:12 AM
Hello all,
I'm a neophyte CPO user and I'm currently tasked with converting some of my powershell/powercli reporting scripts into CPO processes.
Current setup: central CPO server running against Windows management servers at various sites. CPO allows me to run PowerCLI tasks against those servers (hurray!) however I really have no idea how to get the results from that powercli activity into anything else.
To clarify, one of the goals is to retrieve some data (for instance from get-vm) and store that into a database for trend tracking. So far I've gotten the powercli activity to successfully run on the target windows server and successfully run against it's respective vCenter server. But my lack of knowledge within CPO is limiting me from doing much else!
Is it possible to pass the objects retrieved from the powercli activity to another activity within the CPO process? Or will I have to dump all the data to CSV on the management windows server and then use another activity to read that file and send it to SQL? I notice that the powercli activity has an "output" tab but I'm having trouble finding any documentation on how to use this activity.
Thanks!
Solved! Go to Solution.
06-24-2014 11:39 AM
I'm not quite sure on the VMware version of powershell CLI. I was talking to the generic execute powershell CLI which also seems to be used in quite a bit of the IAC solution. However, I think either Derek Evans or Warren Ackerman would have an idea/some experience to pull from and help.
--shaun
06-30-2014 05:58 AM
As Shaun mentions here, the built in Power CLI doesn't really seem to be used much, instead most of the existing IAC powershell activities are performed using the more generic Execute Windows PowerShell activity with the snap-in imported as you have in your existing example.
The approach that seems to work the best is constructing your output as XML and then using something like the Read Table from XML activity to iterate through your results.
e.g.
Write-Output '<results>
If you have access to the IAC content, have a look at some of the discovery processes for some more examples
06-23-2014 05:30 AM
the output tab will output the screen results of the script. Just like if you were sitting at the terminal and typing commands into powershell. If you are running a script that just "does something" then you need to do something like an ECHO.
You will then need to use regex or string activities maybe to get that output, unless you just have a single output, then you can just pass the activities output.
Something like this
$answer = [math]::Round($args[0],$args[1]) echo $answer
06-24-2014 07:19 AM
Thanks!
On the output tab of the PowerCLI activity I have attempted to add table columns for VM (name) and SizeGB (decimal) but when I run the process I get the following error:
PowerCLI script execution failed with the following:
Could not find a property named 'VM' while retrieving output values from the script results.
Now, if I remove those columns from the output tab of the PowerCLI activity and go to the Match Regular Expression activity and point it at [Workflow.Get-VM.Result_Table.Table_Data_XML] the RegEx activity just sees an empty table (even with the ECHO at the end of the PowerCLI activity)
Lastly, if I look at the results of the PowerCLI activity (Get-VM) it does say 3568 objects returned. This is about how many VMs I'd expect Get-VM to return - so the question is how do I get access to those objects in the next activity? I tried xpath query as well to no avail.
Some screenshots:
06-24-2014 11:39 AM
I'm not quite sure on the VMware version of powershell CLI. I was talking to the generic execute powershell CLI which also seems to be used in quite a bit of the IAC solution. However, I think either Derek Evans or Warren Ackerman would have an idea/some experience to pull from and help.
--shaun
06-30-2014 05:58 AM
As Shaun mentions here, the built in Power CLI doesn't really seem to be used much, instead most of the existing IAC powershell activities are performed using the more generic Execute Windows PowerShell activity with the snap-in imported as you have in your existing example.
The approach that seems to work the best is constructing your output as XML and then using something like the Read Table from XML activity to iterate through your results.
e.g.
Write-Output '<results>
If you have access to the IAC content, have a look at some of the discovery processes for some more examples
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide