If a Virtual machine hard disk was increased by some GB.
can i find from POWERCLI ? when it was increased and who increased it ?
i tried using Get-VIEvents and Get-Log but i was not getting the details.
LucFullenwarth I checked this blog - Events - Part 3 : Auditing VM device changes - LucD notes
this is pulling information for all VMs. But how to do it for single VM only.
In LucD's code, you simply need to change :
while($tasks){ $tasks | where {$_.Name -eq "ReconfigVM_Task"} | % {
to
while($tasks){ $tasks | where {$_.Name -eq "ReconfigVM_Task" -and $_.EntityName -eq [vmname]} | % {
You could pass static text for [vmname] or capture a variable each time you run the script and pass that instead. That will tell the loop to only collect the events which are both Reconfigure tasks and associated with that particular VM.
You can also change the Task filter.
This should be a bit faster and place less stress on your vCenter, since only Task objects fitting the filter will be returned.
Lines 10-15 need to be changed to something like this
$tFilter.Time = New-Object VMware.Vim.TaskFilterSpecByTime
$tFilter.Time.beginTime = (Get-Date).AddHours(-$hours)
$tFilter.Time.timeType = "startedTime"
$tFilter.Entity = New-Object VMware.Vim.TaskFilterSpecByEntity
$tFilter.Entity.Entity = (Get-VM -Name <your-VM>).ExtensionData.MoRef
$tCollector = Get-View ($taskMgr.CreateCollectorForTasks($tFilter))
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference