function Get-WebExceptionBody | |
{ | |
param( | |
[int]$Last | |
) | |
if(-not $PSBoundParameters.ContainsKey('Last')){ | |
$Last = 1 | |
} | |
$ex = $Error |? { $_.Exception -is [System.Net.WebException]} |Select -First $Last | |
if($ex){ | |
$resp = $ex.Exception.Response | |
$respstream = $resp.GetResponseStream() | |
$respstream.Position = 0 | |
[System.IO.StreamReader]::new($respstream).ReadToEnd() | |
$respstream.Dispose() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment