Skip to content

Instantly share code, notes, and snippets.

@t2psyto
Last active October 31, 2023 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t2psyto/e0907dd1afc7326ec0f10d05cdf6367f to your computer and use it in GitHub Desktop.
Save t2psyto/e0907dd1afc7326ec0f10d05cdf6367f to your computer and use it in GitHub Desktop.
現在時刻を設定 (yahoo.co.jp のweb応答Dateヘッダーを利用)
@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