Last active
October 31, 2023 05:11
-
-
Save t2psyto/e0907dd1afc7326ec0f10d05cdf6367f to your computer and use it in GitHub Desktop.
現在時刻を設定 (yahoo.co.jp のweb応答Dateヘッダーを利用)
This file contains hidden or 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
@set args=%* | |
@powershell "iex((@('')*3+(cat '%~f0'|select -skip 3))-join[char]10)" | |
@exit /b %ERRORLEVEL% | |
Try { | |
# 現在時刻取得 (yahoo.co.jp のweb応答Dateヘッダーを利用) | |
#$ret = Invoke-WebRequest "http://www.yahoo.co.jp" -Proxy "x.x.x.x:8080" | |
$ret = Invoke-WebRequest "http://www.yahoo.co.jp" | |
if ($ret.StatusCode -eq 200) { | |
$now = [Datetime]$ret.Headers.Date | |
Write-Host $now | |
# 時刻設定 | |
Set-Date -Date $now | |
} | |
} Catch { | |
$RestError = $_ | |
echo $RestError | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment