3 Replies Latest reply on Sep 22, 2020 4:18 AM by LucD

    Snapshot created by

    AymanSammour Lurker

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