Archive

Archive for June, 2011

Powershell – Converting multiple return values to single strings for reports

June 24th, 2011 No comments

Sometimes, you’re writing a little Powercli / Powershell code to generate a report and the repotr you generate retuns multiple values for some lines.

for example, you want a report showing each ESX host in your environment’s mapped VLANs and Datastores – or you’d like to interrogate some servers and return their DNSServers – as single objects.

[string]::Join is your friend here.

for example:

Get-VirtualPortGroup -VMHost $vmhost | %{$_.VlanId}
2598
2599
553
552
638
637
104
119
2470
2460
2951
2465
19
17
50
633
634
635
636

Hmm – this has returned a nice list – but I don;t want a new line for each VLAN.

so let’s join that into a comma sepated string?

[string]::Join(',',(Get-VirtualPortGroup -VMHost $vmhost | %{$_.VlanId}))
2598,2599,553,552,638,637,104,119,2470,2460,2951,2465,19,17,50,633,634,635,636

Ahh – much better!

so now I can generate my original report to find VLANs and Datastores mapped to hosts in my cluster

get-cluster $cluster | Get-VMHost | Select Name,
    @{N="VLAN";E={[string]::Join(',',(Get-VirtualPortGroup -VMHost $_ | %{$_.VlanId}))}},
    @{N="Datastore";E={[string]::Join(',',(Get-Datastore -VMHost $_ | %{$_.Name}))}}
Name                                              VLAN                                              Datastore
----                                              ----                                              ---------
LABESX8.get-virtual.info                         3410,3415,3430,3435,3425,3420,0,0,2640           LABSTG112L055,LABSTG112L062,LABSTG112L012..
labesx17.get-virtual.info                         3410,3415,2640,3425,3435,3430,3420,0,0,0         LABSTG112L055,LABSTG112L062,LABSTG112L099..
labesx18.get-virtual.info                         3410,3415,3430,3435,3425,3420,0,0,2640           LABSTG112L055,LABSTG112L062,LABSTG112L099..
labesx21.get-virtual.info                         3410,3415,2640,3435,3430,3425,3420,0,0           LABSTG112L055,LABSTG919119,LABSTGHA919L116_FI,..
labesx40.get-virtual.info                         3410,3415,2640,3435,3430,3425,3420,0,0           LABSTG112L055,LABSTG112L062,LABSTG112L099..
labesx25.get-virtual.info                         3410,3415,2640,3435,3430,3420,3425,0,0           LABSTG112L055,LABSTG919119,LABSTGHA919L116_FI,..

the magic lies here:

[string]::Join(',',(

What this is saying is joing the response from the following queery – into 1 string . .seperated by ‘,’

job done – pretty reports here we come!

Categories: Powershell, VMWare Tags:

vSphere 5 to be launched 12th July?

June 24th, 2011 No comments

This morning I received an email from VMware to a live webinar:

Raising the Bar, Part V
July 12, 2011
9 a.m. Pacific time

Featuring
Paul Maritz
VMware CEO

Stephen Herrod
VMware CTO and SVP of R&D

Hmm . . the next step forward – I can only imagine that it is one thing . . surely, the official launch for vSphere 5? (I am guessing here . . but this seems to be the common perception amongst pretty much all VM blogs / communities)

I believe all users registered for VMware updates got this – if it interesrts you . . you may want to try book onto the webinar?

If this is the case then hopefully VCP exams on it should be available September: prepare your labs now!

Categories: News Tags:

VMware community – Moderator elections

June 1st, 2011 No comments

I received an email from Alex Maier (VMware community Manager).
I am thrilled to be able to say that I have been elected as a VMWare community moderator for the upcoming 6 months.

I am really happy with this as it should give me ample opportunity to give a little back to the community.

I am looking forward to it.

Categories: VMWare Tags: