Automation

 View Only
  • 1.  VMware Folder Resource Report

    Posted Oct 06, 2017 01:51 PM

    I am looking for a way to get a resource report for a set of VMs. Things like CPUs assigned, RAM assigned, HDD assigned, & HDD used, but I want to be able to point it at a VM folder so it will dynamically grow as the group does.  Looking for any ideas on how to do this.

    Thanks,

    Andy



  • 2.  RE: VMware Folder Resource Report

    Posted Oct 06, 2017 01:57 PM

    As a concept, the core of that script could look something like this.

    And yes, it doesn't provide the metrics you mentioned, but just to verify this is what you want.

    You would also need to know over which time interval you want the script to collect these statistics.
    And does the script need to average the statistical data, or produce a line per time at which statistics are available?

    $folderName = 'MyFolder'

    $entity = Get-Folder -Name $folderName | Get-VM

    Get-Stat -Entity $entity -Realtime -MaxSamples 1



  • 3.  RE: VMware Folder Resource Report

    Posted Oct 06, 2017 02:12 PM

    Well I am not looking for an over time report, just a report showing how much resources are being allocated at a point in time.  Again just CPU, RAM, and HDD allocations and then how much HDD is being used at that point in time.  We really would only run this quarterly I believe and be kicked off manually.



  • 4.  RE: VMware Folder Resource Report

    Posted Oct 06, 2017 02:28 PM

    Luc probably has a better way but something like this perhaps.

    $folder = 'MyFolderName'

    $vms = Get-Folder $folder | Get-VM

    $vms | Select-Object Name,MemoryGB,NumCpu,

    @{n="TotalHDSizeGB"; e={(Get-HardDisk -VM $_ |Measure-Object -Sum CapacityGB).Sum}},

    @{ n="SpaceUsedGB"; e={[math]::round( $_.UsedSpaceGB )}}



  • 5.  RE: VMware Folder Resource Report

    Posted Oct 06, 2017 03:29 PM

    Looking good, can you output this to a CSV so we can add them together quickly and tell the dept to pay up :smileysilly:



  • 6.  RE: VMware Folder Resource Report
    Best Answer

    Posted Oct 07, 2017 12:54 AM

    How about something like this.. Also if you want to run this as a schedule you might consider encrypting the credentials like this

    Get-Credential –Credential “administrator@vsphere.local” | Export-Clixml C:\Scripts\mycreds.xml

    $vc = 'vca.vsphere.local'

    $folder = 'VM_folder'

    $reportpath = 'c:\vm_report\vms.csv'

    $Cred = Get-Credential

    #$Cred = Import-Clixml C:\Scripts\mycreds.xml

    Connect-VIServer $VC -Credential $Cred

    $vms = Get-Folder $folder | Get-VM

    $vms | Select-Object @{e={$_.name};L="VM Name"},

    @{e={$_.NumCpu};L="Number of vCPU's"},

    @{e={$_.MemoryGB};L="Allocated Memory GB"},

    @{n="Total Disk Size GB"; e={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}},

    @{n="Total Disk Space Used GB"; e={[math]::round( $_.UsedSpaceGB )}}|

    Export-Csv -Path $reportpath -NoTypeInformation

    Disconnect-VIServer $vc -Force -Confirm:$false

    Remove-Variable * -Force -ErrorAction SilentlyContinue 



  • 7.  RE: VMware Folder Resource Report

    Posted Oct 10, 2017 02:38 PM

    @nicholas1982 Thank you so much for explaining how to properly hide my creds that is another project I was working on.  And the script is nearly perfect!

    Thank you for the help!