Last active
July 7, 2020 13:39
-
-
Save kazu0617/097dd8eb5840c1bc1a04d9c24f2ff017 to your computer and use it in GitHub Desktop.
mydnsの更新に使っていました。あげてると思ってたらなかったので。使用方法: コマンドラインorタスクスケジューラにて「$DDNSUpdate.ps1 ID Pass」と入力。
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
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