Monitor DHCP Scope Available Addresses with PowerShell

Had an influx of folks come into the office last week and one of our DHCP Scopes actually almost ran out of available addresses (which I found out after the fact by chance).  This inspired me to make a quick PowerShell script deployed as a scheduled task to notify me when a scope is low on available addresses, as seen below:


Error: 200010 When Configuring DHCP Failover

When attempting to configure DHCP Failover using Server 2012R2 I kept running into this issue.  The issue was that I had a custom scope option for my phone system that I had not added to my second DHCP server.  Once I added the custom scope option to the second DHCP server (right click IPv4 and select the “Set Predefined Options…” option) everything went off without a hitch.