Last active
December 27, 2015 19:21
-
-
Save sytone/2495a69c352623b6c9bd to your computer and use it in GitHub Desktop.
Returns the DHCP list for a ASUS router.
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
$username = "admin" | |
# read-host -assecurestring | convertfrom-securestring | out-file .\securestring.txt | |
$password = cat .\securestring.txt | convertto-securestring | |
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | |
$page = Invoke-WebRequest -Uri "http://192.168.0.1/Main_DHCPStatus_Content.asp" -Credential $cred | |
$dhcpList = $page.AllElements | where tagName -eq "textarea" | Select -First 1 -ExpandProperty innerText | |
$rows = @() | |
$dhcpList.split("`n")[(1..($dhcpList.split("`n").Length-1))] | % { | |
$row = $_.split(" ",[StringSplitOptions]'RemoveEmptyEntries') | |
[PSCustomObject]@{ | |
IP = $row[1]; | |
MACAddress = $row[2]; | |
Expires = [int]($row[3].split(":")[0])*60*60 + [int]($row[3].split(":")[1])*60 + [int]($row[3].split(":")[2]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment