VMware Cloud Community
jkb5054
Contributor
Contributor

All vCloud VMs in a provider vDC

Trying to get all VMs use a provider. The issue is making the call from the provider to then get all the vApps - it cannot be made this way Smiley Sad

Does anyone have a clean way of perfroming this action? ( A whole cluster (One of the many provider vDCs we have ) is going down, so i would like to generate a list.

Every Org has anywhere from 1-5 organization vDCs, so parsing it that way is a last resort in my book.

Thoughts? Suggestions?

$report = @()

$list = Get-ProviderVdc "Provider vDC" | get-civapp

foreach ($Vapp in $list){
    $vms = $vapp | get-civm
        foreach($vm in $vms){
        if($vm) {
            $vm | %{
    $row = "" | select "name", "owner", "Email"
    $row."name" = $_.name
    $row."owner" = $vapp.Owner.FullName
    $row."Email" = $vapp.Owner.Email
   
    }
    }
    $report += $row
    }
    }
   
    $report = $report | Sort-Object -Property Owner
   
    $report | export-csv "C:\Vcloud-cluster-VMs.csv" -NoTypeInformation -UseCulture

0 Kudos
2 Replies
jake_robinson_b
Hot Shot
Hot Shot

Have you played with the Search-Cloud cmdlet?

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
0 Kudos
dmilov
VMware Employee
VMware Employee

Hi, here is how to get this report:

$report = Get-ProviderVdc "Provider vDC" | Get-OrgVdc | Get-CIVM | foreach {

     $row = "" | select Name, Owner, Email;

     $row.Name = $_.Name;

     $row.Owner = $_.VApp.Owner.Name;

     $row.Email = $_.VApp.Owner.Email;

     $row

}

$report = $report | Sort-Object -Property Owner

$report | Export-Csv "C:\Vcloud-cluster-VMs.csv" -NoTypeInformation -UseCulture

Dimitar Milov
PowerCLI Team

0 Kudos