There seems to have been a bug with the AutoFilter switch.
Original Message:
Sent: Nov 13, 2024 03:14 AM
From: ganapa2000
Subject: Unable to get VM Info based on particular folders
That worked LucD. Not sure, why it was not gathering with autofilter option all of a sudden?
Original Message:
Sent: Nov 11, 2024 02:48 PM
From: LucD
Subject: Unable to get VM Info based on particular folders
"HR folder 126 VMs but it is gathering only 67 VMHR folder 126 VMs but it is gathering only 67 VM"
Do I understand correctly that you do get a partial list for the VMs in the HR folder?
Did you try leaving out the AutoFilter switch on the Export-Excel cmdlet?
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 11, 2024 12:06 PM
From: ganapa2000
Subject: Unable to get VM Info based on particular folders
LucD,
I am able to get the information from all the folder except HR. HR folder 126 VMs but it is gathering only 67 VM information. There are no subfolders in HR.
But If execute Get-Folder HR | Get-VM command, I am able to get all 126 VMs list but from above script is fetching only 67 VMs info
Original Message:
Sent: Nov 11, 2024 05:29 AM
From: LucD
Subject: Unable to get VM Info based on particular folders
Try like this
$vmNotesInfo = @()Foreach ($vc in $global:DefaultVIServers){ $vmNotesInfo += Get-Folder "HR", "DevOps", "Release-1" -Server $vc | Get-VM -Server $vc | Select @{N='vCenter';E={([uri]$_.ExtensionData.Client.ServiceUrl).Host}}, @{N="Folder"; E={$_.Folder.Name}}, @{N='VM Name';E={$_.Name}}, @{N="IP Address";E={($_.guest.IPAddress[0])}}, @{N="VM PowerState";E={($_.PowerState)}}, @{N="Operating System"; E={@($_.guest.OSFullName)}}, @{N="CPU Count";E={@($_.NumCPU)}}, @{N="MemoryInGB";E={[math]::round($_.MemoryGB)}}, @{N="HardDiskSizeGB"; E={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}}, @{N="Notes";E={@($_.Notes)}}}$vmNotesInfo | Export-Excel -Path $reportlocation1 -AutoFilter -AutoSize -WorksheetName All_VMs_Info
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 11, 2024 03:32 AM
From: ganapa2000
Subject: Unable to get VM Info based on particular folders
Hi,
I am trying to get the VM information from multiple vCenters, where few folders are not present on few vCenters
for example, HR folder exists on all vcenters but If the HR folders has 10 VMs in vCenter 1, it gathers and output in output file but same HR folder on vcenter 2 has more than 10 VMs, it would gather only 10 VM info. It is not gathering for all VMs in vcenter2
Please help!!!
$vmNotesInfo = Foreach ($vc in $global:DefaultVIServers)
{
Get-Folder "HR", "DevOps", "Release-1" -Server $vc | Get-VM -Server $vc | Select @{N='vCenter';E={([uri]$_.ExtensionData.Client.ServiceUrl).Host}},
@{N="Folder"; E={$_.Folder.Name}},
@{N='VM Name';E={$_.Name}},
@{N="IP Address";E={($_.guest.IPAddress[0])}},
@{N="VM PowerState";E={($_.PowerState)}},
@{N="Operating System"; E={@($_.guest.OSFullName)}},
@{N="CPU Count";E={@($_.NumCPU)}},
@{N="MemoryInGB";E={[math]::round($_.MemoryGB)}},
@{N="HardDiskSizeGB"; E={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}},
@{N="Notes";E={@($_.Notes)}}
}
$vmNotesInfo | Export-Excel -Path $reportlocation1 -AutoFilter -AutoSize -WorksheetName All_VMs_Info