Hello,
I am new to VMware. I was wondering if anyone can help me get on the right track. I am trying to find a way to write a script that will check to see if the VMs that have not been used within 90 days and turn power it off.
Any help would be great..
Thanks
In that case you could consider using the cpu.usage.average counter on the VM, and if the average value doesn't exceed a specific threshold, you consider it as not used.
You use the Get-Stat cmdlet to retrieve the metric.
Note that if you back further than 30 days, you will only get 1 metric per day.
This is because of the aggregation that is done, see my PowerCLI & vSphere statistics – Part 1 – The basics post for some more info on that.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How do you define "not used" ?
Not powered on, no activity on the VM, no actual logons into the guest OS ... ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not used as in no activity on the VM
In that case you could consider using the cpu.usage.average counter on the VM, and if the average value doesn't exceed a specific threshold, you consider it as not used.
You use the Get-Stat cmdlet to retrieve the metric.
Note that if you back further than 30 days, you will only get 1 metric per day.
This is because of the aggregation that is done, see my PowerCLI & vSphere statistics – Part 1 – The basics post for some more info on that.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference