I am trying to write automation, which can fetch active, allocate and consume memory at VM level and print esxhost name as well (between specific hours for 2 weeks)
If someone has ready script in powercli, can you please share with me.
-A
Basically you use the Get-Stat cmdlet for that.
The available memory counters are described under the PerformanceManager in the SDK API Reference.
I have a couple of posts that give an intro on doing performance reporting from PowerCLI.
See PowerCLI & vSphere statistics – Part 1 – The basics and PowerCLI & vSphere statistics – Part 2 – Come together to start with.
And there are quite a lot of samples of such scripts in this PowerCLI Community.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Alan also has a One-Liner that you probably could modify with some of the stats you want to use.
To see the available memory stat types you can run e.g.: $vm | Get-StatType *mem*