VMware Cloud Community
bvi1006
Enthusiast
Enthusiast

Creating output which includes the virtual center name

Hi,


I'm trying to to get the virtual center name while creating an array of clusters by using the following which will be piped out to out-datatable.

$dt = @($Clusters | Select @{N="Cluster_Name";E={$_.Name}}) | Out-DataTable

I know I'm already connected to the virtual center and can set a variable, but how to merge with this information so that I can write it to sql?

Thanks!

Tags (1)
0 Kudos
4 Replies
LucD
Leadership
Leadership

Try something like this

$dt = @($Clusters | 
Select @{N="Cluster_Name";E={$_.Name}}), 
@{N="vCenter";E={$_.Uid.Split('@')[1].Split('/')[0]}} |
Out-DataTable


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
bvi1006
Enthusiast
Enthusiast

Thanks Luc. Can you tell me where I might have found this information, ie the uid info? Then I might not have to ask so many questions Smiley Wink

0 Kudos
LucD
Leadership
Leadership

You can look at the PowerCLI reference, find the Get-Cluster cmdlet.

Look at the output, the Cluster object.

Display the Cluster object (from the PowerCLI prompt or in a Gui).

For example:

Get-Cluster MyCluster | Format-Custom -Depth 5

This will produce a long list of properties and their values. (It's a lot easier when you can use a Gui that has a variable inspector).

You will at some point notice the Uid property, and hidden in the value there is the name of the vCenter.

There is no real article/post/book that will guide you all the way (there are just too many properties).

Start playing and inspect the objects that are returned.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
bvi1006
Enthusiast
Enthusiast

Thanks for the information, I appreciate it. 

0 Kudos