Skip to content

Instantly share code, notes, and snippets.

@kazu0617
Last active July 7, 2020 13:39
Show Gist options
  • Save kazu0617/097dd8eb5840c1bc1a04d9c24f2ff017 to your computer and use it in GitHub Desktop.
Save kazu0617/097dd8eb5840c1bc1a04d9c24f2ff017 to your computer and use it in GitHub Desktop.
mydnsの更新に使っていました。あげてると思ってたらなかったので。使用方法: コマンドラインorタスクスケジューラにて「$DDNSUpdate.ps1 ID Pass」と入力。
param([string]$USER,[string]$PASSWD)
$webReq = [Net.HttpWebRequest]::Create("http://www.mydns.jp/login.html")
$webReqv4 = [Net.HttpWebRequest]::Create("http://ipv4.mydns.jp/login.html")
$webReq.Credentials = New-Object System.Net.NetworkCredential($USER, $PASSWD)
$webReqv4.Credentials = New-Object System.Net.NetworkCredential($USER, $PASSWD)
try {
$webRes = $webReq.GetResponse()
$webRes.Close()
$webResv4 = $webReqv4.GetResponse()
$webResv4.Close()
write("ipv4.v6update: {0} {1}" -f [int]$webRes.StatusCode,$webRes.StatusCode)
} catch [System.Net.WebException] {
$excRes = $_.Exception.Response
[System.Net.HttpWebResponse]$webRes = $excRes
$excRes.Close()
write("ipv4.v6update: {0} {1}" -f [int]$webRes.StatusCode,$webRes.StatusCode)
}
Start-Sleep -s 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment