Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

finding the snapshot creator

$
0
0

Hey guys - I found this script which is running fine except that it doesn't seem to show the users who created the snapshots unless they were created by veeam - running 5.5 u3

 

Any thoughts about how to extract the user who created the snapshot?

 

Thanks!

 

#Script for getting VMs and their snapshot information from ESXi Server/vCenter 4+
#original by virtualcurtis (http://virtualcurtis.wordpress.com)
#modified by Christian
# - disabled "has a snapshot"-Output
# - modified for german ESXi 4.1
# - added snapshot name and description
# - increased MaxSamples value from 1000 to 5000

 

$myVMs = Get-VM
$VMsWithSnaps = @()
foreach ($vm in $myVMs) {
    $vmView = $vm | Get-View
    if ($vmView.snapshot -ne $null) {
        #Write-Host "VM $vm has a snapshot"
        $SnapshotEvents = Get-VIEvent -Entity $vm -type info -MaxSamples 5000 | Where {
            $_.FullFormattedMessage.contains("Get a snapshot")}
        try {
        $user = $SnapshotEvents[0].UserName
        $time = $SnapshotEvents[0].CreatedTime
        } catch [System.Exception] {
             $user = $SnapshotEvents.UserName
             $time = $SnapshotEvents.CreatedTime
        }

#Get snapshot information
$SnapshotInfo = Get-Snapshot $vm

$VMInfo = "" | Select "VM","Name","Description","CreationDate","User"
        $VMInfo."VM" = $vm.Name
$VMInfo."Name" = $SnapshotInfo.Name
$VMInfo."Description" = $SnapshotInfo.Description
        $VMInfo."CreationDate" = $time
        $VMInfo."User" = $user
        $VMsWithSnaps += $VMInfo
    }
}
$VMsWithSnaps | Sort CreationDate


Viewing all articles
Browse latest Browse all 168455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>