VMware Cloud Community
mdangel1
Enthusiast
Enthusiast
Jump to solution

Script to determine who created a snapshot

Hello All

I have the following script, I need help in adding code to determine who created the snapshot.

Get-VM | Get-Snapshot | Where { $_.Created -lt (Get-Date).AddDays(-2)} | select VM, Name, Created, SizeMB

0 Kudos
1 Solution

Accepted Solutions
kunaludapi
Expert
Expert
Jump to solution

try this,

get-vm | get-vievent | where-object {$_.fullformattedmessage -like "*snapshot*"} | Select-object @{N="VM"; E={$_.vm.name}}, username, FullFormattedMessage, CreatedTime

It will report snapshot deletion event as well.

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Have a look at Alan's PowerCLI: SnapReminder


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
mdangel1
Enthusiast
Enthusiast
Jump to solution

I tried adding the Get-SnapshoCreator but its not working. I do not need to send an email, I just need to know who created it

0 Kudos
kunaludapi
Expert
Expert
Jump to solution

try this,

get-vm | get-vievent | where-object {$_.fullformattedmessage -like "*snapshot*"} | Select-object @{N="VM"; E={$_.vm.name}}, username, FullFormattedMessage, CreatedTime

It will report snapshot deletion event as well.

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The previous solution provides an incomplete report, since it doesn't link the snapshot to the user.

Try the attached script, it is based on my Get-VIEventPlus function, and it is a simplified version of my Get-SnapshotExtra function in Alan's script.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos