Automation

 View Only
  • 1.  Get VM Reconfigure Details from PowerCLI

    Posted Nov 22, 2019 01:11 PM

    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.



  • 2.  RE: Get VM Reconfigure Details from PowerCLI

    Posted Nov 22, 2019 01:48 PM

    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.



  • 3.  RE: Get VM Reconfigure Details from PowerCLI

    Posted Nov 22, 2019 03:22 PM

    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))