<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Monitoring on Alfred van Ster</title><link>https://avanster.tech/tags/monitoring/</link><description>Recent content in Monitoring on Alfred van Ster</description><generator>Hugo -- 0.161.1</generator><language>en-us</language><lastBuildDate>Sun, 03 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://avanster.tech/tags/monitoring/index.xml" rel="self" type="application/rss+xml"/><item><title>Infrastructure: Hyper-V Orphaned Snapshot Monitor</title><link>https://avanster.tech/library/script-hyperv-snapshot-monitor/</link><pubDate>Sun, 03 May 2026 00:00:00 +0000</pubDate><guid>https://avanster.tech/library/script-hyperv-snapshot-monitor/</guid><description>&lt;ol&gt;
&lt;li&gt;The Workflow&lt;/li&gt;
&lt;li&gt;The Implementation&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A common L3 infrastructure issue is technicians taking a VM checkpoint before an update and forgetting to delete it. This script scans for stale snapshots and fires an alert to a Microsoft Teams or Slack webhook.&lt;/p&gt;
&lt;h3 id="1-the-workflow"&gt;1. The Workflow&lt;/h3&gt;
&lt;p&gt;The script performs the following steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Discovery:&lt;/strong&gt; Scans the local Hyper-V host for all active checkpoints.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Evaluation:&lt;/strong&gt; Compares the creation date of the snapshot against a 7-day threshold.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alerting:&lt;/strong&gt; If stale snapshots exist, it constructs a JSON payload and POSTs it to a designated webhook URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="2-the-implementation"&gt;2. The Implementation&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ThresholdDate = (Get-Date).AddDays(&lt;span style="color:#ae81ff"&gt;-7&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$StaleSnapshots = Get-VM | Get-VMSnapshot | Where-Object { $_.CreationTime &lt;span style="color:#f92672"&gt;-lt&lt;/span&gt; $ThresholdDate }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ($StaleSnapshots) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $Payload = @{ text = &lt;span style="color:#e6db74"&gt;&amp;#34;⚠️ Orphaned Snapshots Detected on &lt;/span&gt;$env:COMPUTERNAME&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; } | ConvertTo-Json
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Invoke-RestMethod -Uri &lt;span style="color:#e6db74"&gt;&amp;#34;[https://your-webhook.url](https://your-webhook.url)&amp;#34;&lt;/span&gt; -Method Post -Body $Payload -ContentType &lt;span style="color:#e6db74"&gt;&amp;#34;application/json&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>