Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

powercli reporting in CPO

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!

Everyone's tags (3)
2 ACCEPTED SOLUTIONS

Accepted Solutions
Cisco Employee

I'm not quite sure on the

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

--Shaun Roberts shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
New Member

As Shaun mentions here, the

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>'

#Loop through each VM here and output in new XML tag(s)

Write-Output '</results>'

 

If you have access to the IAC content, have a look at some of the discovery processes for some more examples

4 REPLIES
Cisco Employee

the output tab will output

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
--Shaun Roberts shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
New Member

Thanks!On the output tab of

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:

 

 

Cisco Employee

I'm not quite sure on the

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

--Shaun Roberts shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
New Member

As Shaun mentions here, the

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>'

#Loop through each VM here and output in new XML tag(s)

Write-Output '</results>'

 

If you have access to the IAC content, have a look at some of the discovery processes for some more examples

118
Views
0
Helpful
4
Replies
CreatePlease login to create content