Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180923

How to display vm's snapshot list in a formatted way in windows event logs? Is there any alternate method to create alarm when snapshot exists more than 24 hours?

$
0
0

I was able to create events and display vm snaphot which exists more then 24 hours. But vms created appear in a single line as shown in first image in windows event logs. Please let me know how to get the desired out image in which vms should appear one below the other.

Also if there is any alternate method to create alarm when snapshot exists for more than 24 hours would be helpful?

 

Code-

$SnapVMlist = Get-VM | Get-Snapshot | Where {$_.Created -lt [datetime]::Now.AddDays(-1)} | Select VM, Name, Created

Get-VM | Get-Snapshot | Where {$_.Created -lt [datetime]::Now.AddDays(-1)} | Select-Object VM, Name, Created | Out-File -FilePath C:\Users\Administrator\VMSnapMonitor.txt

$snapcount = $SnapVMlist.Count

$file= Get-Content C:\Users\Administrator\VMSnapMonitor.txt

New-EventLog -LogName System -Source GMES2

if ($snapcount.count -gt 0){

    eventcreate /ID 102 /L SYSTEM /T ERROR /SO "GMES2" /D "$file"

}

 

vmsnap.jpgjavascript:;vmsnap3.jpg

 

Any assistance that I can get would be much appreciated.

Thank you


Viewing all articles
Browse latest Browse all 180923

Trending Articles



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