Get RedirectUri on PowerShell

Photo by Marc Rentschler on Unsplash

PowerShell で curl -w “%{redirect_url}” 相当がしたくなったのでメモ.

Param(
    [String]$Uri
)
$request = Invoke-WebRequest -Method Head -Uri $Uri
$redirectedUri = $request.BaseResponse.ResponseUri.AbsoluteUri
echo $redirectedUri