Last active
August 22, 2018 22:30
-
-
Save BenNeise/6bff34ad037275723969 to your computer and use it in GitHub Desktop.
Restarts a Virgin Media Suberhub using the web interface.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Restart-VirginRouter { | |
<# | |
.Synopsis | |
Restarts a Virgin Media Suberhub. | |
.Description | |
Restarts a Virgin Media Suberhub using the web interface. | |
.Parameter RouterIP | |
The IP address of the router. | |
.Parameter Username | |
The username used to log into the web interface. | |
.Parameter Password, | |
The password used to log into the web interface. | |
.Example | |
Restart-VirginRouter -RouterIP "192.168.0.1" -Username "admin" -Password "hunter2" | |
Restarts the router using the specified credentials. | |
.Notes | |
Ben Neise 23/02/15 | |
#> | |
param ( | |
[Parameter( | |
Mandatory = $true, | |
Position = 1 | |
)] | |
[string] | |
$RouterIP, | |
[Parameter( | |
Mandatory = $true, | |
Position = 2 | |
)] | |
[string] | |
$Username, | |
[Parameter( | |
Mandatory = $true, | |
Position = 3 | |
)] | |
[string] | |
$Password | |
) | |
# Login | |
$loginParams = @{ | |
VmLoginUsername = $username; | |
VmLoginPassword = $password; | |
VmLoginErrorCode = 0; | |
VmChangePasswordHint = 0 | |
} | |
$r1 = Invoke-WebRequest -Uri ("http://" + $routerIP + "/") -SessionVariable "Session" -Verbose | |
Invoke-WebRequest -Uri ("http://" + $routerIP + $r1.forms[0].action) -Method "POST" -Body $loginParams -WebSession $Session -Verbose | |
# Restart | |
$restartParams = @{ | |
VmDeviceRestore = 0; | |
VmDeviceReboot = 1 | |
} | |
$r2 = Invoke-WebRequest -Uri ("http://" + $routerIP + "/VmRgRebootRestoreDevice.asp") -WebSession $Session -Verbose | |
Invoke-WebRequest -Uri ("http://" + $routerIP + $r2.forms[0].action) -Method "POST" -Body $restartParams -WebSession $Session -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment