VMware Cloud Community
Hot Shot
Hot Shot

Get VM Reconfigure Details from PowerCLI

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.

Tags (1)
0 Kudos
2 Replies
Hot Shot
Hot Shot

In LucD​'s code, you simply need to change :

while($tasks){ $tasks | where {$_.Name -eq "ReconfigVM_Task"} | % {


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.

0 Kudos

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 = New-Object VMware.Vim.TaskFilterSpec

$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