I've searched around for this but am not really finding anything this specific. I'm running a nightly export similar to this:
$TestWinVMList = @() # Get all VMs | Keep only PoweredOn | Iterate over all of the results. Get-View –viewtype VirtualMachine | Foreach-object { # Skip if powered off if ($_.Summary.Runtime.Powerstate -eq "poweredOff") { return } If ($_.Config.GuestFullName.startswith("Microsoft")) { $obj = "" | Select u_name, u_hostname, u_disk, u_ram, u_ip_address, u_mac_address, u_os $obj.u_name = $_.Name $obj.u_hostname = $_.Guest.HostName If (!$obj.u_hostname) {$obj.u_hostname = "$($obj.u_name)" + ".phci.org"} $diskField = $null $_.Guest.disk | Sort DiskPath | foreach-object { $diskField += "$($_.DiskPath) $([math]::Round($_.Capacity / 1073741824)) GB " } $obj.u_disk = $diskField $obj.u_ram = [string]([int] $_.Summary.Config.MemorySizeMB / 1024) + " GB" $obj.u_ip_address = $_.Guest.Net.IPAddress -join ", " $obj.u_mac_address = $_.guest.net.MacAddress -join ", " $obj.u_os = $_.Config.GuestFullName $TestWinVMList += $obj }
Let's say there's 3 clusters in a vCenter and I don't want to pull data from one of them. How do I tell Get-View to exclude all VMs in a specific cluster?