You know your ISP is having issues if you have to plug your cable modem into a Wemo switch and power cycle it with a PowerShell script when you drop internet. I did this because I got tired of unplugging and plugging the modem back in just to get internet for another hour (and it is just fun). I did reserve the IP address for my Wemo switch.

​​​​​​​

Here are the straight forward functions to turn on/off the switch. All I did was ping something (www.google.com) every 30 seconds. If it didn't come back, I called both functions to do the power cycle and waited 2 minutes for the internet to come back.

Code: function Turn-WemoOff { <# .SYNOPSIS Turns off a Wemo Switch .DESCRIPTION Turns off a Wemo Switch #> param ( [Parameter(Mandatory=$true)] [string]$ipAddress ) # Set the URL $url = "http://" + $ipAddress + ":49153/upnp/control/basicevent1" # Set the body $body = @" <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"> <BinaryState>0</BinaryState> </u:SetBinaryState> </s:Body> </s:Envelope> "@ # Send the request $result = Invoke-WebRequest -Uri $url -Body $body -ContentType "text/xml" -Method POST -Headers @{"SOAPACTION" = "`"urn:Belkin:service:basicevent:1#SetBinaryState`""} # Return the result return $result }

Code: function Turn-WemoOn { <# .SYNOPSIS Turns on a Wemo switch .DESCRIPTION Turns on a Wemo switch #> param ( [Parameter(Mandatory=$true)] [string]$ipAddress ) # Set the URL $url = "http://" + $ipAddress + ":49153/upnp/control/basicevent1" # Set the body $body = @" <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"> <BinaryState>1</BinaryState> </u:SetBinaryState> </s:Body> </s:Envelope> "@ # Send the Request $result = Invoke-WebRequest -Uri $url -Body $body -ContentType "text/xml" -Method POST -Headers @{"SOAPACTION" = "`"urn:Belkin:service:basicevent:1#SetBinaryState`""} # Return the result return $result }