Hello PowerCLI experts
im using Vmware Vcenter6
is there a way using powercli script that i can get a list of all VM's machines in Vcenter that has a parameter in sched.mem.minsize = "0" greatre then "0" in the VMX file?
Thanks!
Have a look at 6. Re: script to check a setting in a vmx file for specific entry
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd
thanks for your answer!
i have 2 questions:
1. i have 10 datastores, does this script knows to search them all?
2. regarding the correct argument for my purposes, is that the correct syntax for me:
$tgtString = 'sched.mem.minsize = "0" = ">1"'
the goal is to find a vm that has memory reservation greater then 1MB...
Thanks!
1) The script uses the path of the VMX file, it the datastores are accessible, that shouldn't be a problem.
2) No, you should read the string, then extract the value and compare the extracted value
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
With this small script you can check all VMs and list all that have the reservation bigger then 0
$Cluster = Get-Cluster "Cluster test"
$VMs = $Cluster | Get-VM
foreach ($VM in $VMs)
{
$vmview = $vm | get-view
$VMmem = $vmview.summary.config.MemoryReservation
if ($VMmem -ge '1')
{
Write-Host "VM Name:" -foreground DarkBlue -nonewline; Write-Host " " $vm -foreground DarkGray -nonewline; Write-Host " - Reservation is " -foreground DarkBlue -nonewline; Write-Host $VMmem -foreground DarkGray
}
}
Hope this can help
is it possible to not give a direct path to one vmx at a time and instead to search vmx in all datastores available?
Yes, that would require the use of the SearchDatastoreSubFolders on the HostDatastoreBrowser, there you can specify a filter to look for all VMX files (VmConfigFileQuery).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks but im looking for a way to look in the vmx file because there is a known issue that sometimes the vmx file is configured with reservation but you cannot see it in the vsphere client or web client and the script that you provided will not show it