intial description
Mandatory requirement is as below :
Powercli module along with powershell and the excel to open generated csv file
Sample report is as below
-------------------------------------------------------------------------------------------------------------
Copy the code below and save it as file.ps1
-----------------------------------------------------------------------------------------------------------------------------------------------
Import-Module VMware.VimAutomation.Core
$Vcenter= get-content Vcenter.txt
foreach ($vmhost in $Vcenter)
{
Connect-VIServer $Vmhost -User administrator@vsphere.local -Password Vcenter@1234
Get-vmhost | Select Name,
@{N='CPU GHz Capacity';E={[math]::Round($_.CpuTotalMhz/1000,2)}},
@{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}},
@{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}, `
@{N="Memory Usage (Average), %" ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `
@{N="Network Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat net.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `
@{N="Disk Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} |
Export-Csv .\report.csv -NoTypeInformation -UseCulture
}
Thanks