web client - How to get response using WebClient in powershell -
i saw following code in stackoverflow :
$uri = "http://google.com" $wc = new-object system.net.webclient $wc.usedefaultcredentials = $true $json = $wc.downloadstring($uri) and working fine , wandering for, somehow store status code of url hitting.
actually when hitting url having status 404 , returning exception same.
can me regarding how can store status or if can store exception returning back.
this should starting point you:
#requires -version 3 $out = invoke-webrequest -uri 'http://google.com' -usedefaultcredentials -sessionvariable 'conn' then can check $conn connection details. $out have status, returns, etc. $out.statuscode = 200 in example.
Comments
Post a Comment