Automation

 View Only
  • 1.  Snapshot created by

    Posted Sep 22, 2020 08:47 AM

    I have the below script works fine, but the issue I am having, some of the returned results do not have the Created by user; and if the tasked was scheduled it will also not populate the created by, any help would be appreciated 

    foreach ($snap in Get-VM | Get-Snapshot)

    {$snapevent = Get-VIEvent -Entity $snap.VM -Types Info -Finish $snap.Created -MaxSamples 1 | Where-Object {$_.FullFormattedMessage -imatch 'Task: Create virtual machine snapshot'}

    if ($snapevent -ne $null){Write-Host ( "VM: "+ $snap.VM + ". Snapshot '" + $snap + "' created on " + $snap.Created.DateTime + " by " + $snapevent.UserName +".")}

    else {Write-Host ("VM: "+ $snap.VM + ". Snapshot '" + $snap + "' created on " + $snap.Created.DateTime + ". This event is not in vCenter events database")}}



  • 2.  RE: Snapshot created by

    Posted Sep 22, 2020 09:09 AM

    If the information is not in the TaskEvent, I'm not sure that information is even available at all.



  • 3.  RE: Snapshot created by

    Posted Sep 22, 2020 11:03 AM

    but this is only happening when a snapshot  task  is Scheduled



  • 4.  RE: Snapshot created by

    Posted Sep 22, 2020 11:19 AM

    Yes, indeed.