cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
656
Views
0
Helpful
4
Replies

powercli reporting in CPO

davshapi
Level 1
Level 1

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!

2 Accepted Solutions

Accepted Solutions

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
Principal Engineer, CX
shaurobe@cisco.com

View solution in original post

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

View solution in original post

4 Replies 4

Shaun Roberts
Cisco Employee
Cisco Employee

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
Principal Engineer, CX
shaurobe@cisco.com

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:

 

 

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
Principal Engineer, CX
shaurobe@cisco.com

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

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: