powershell 2.0 try catch how to access the exception
Try something like this: try { $w = New-Object net.WebClient $d = $w.downloadString(‘http://foo’) } catch [Net.WebException] { Write-Host $_.Exception.ToString() } The exception is in the $_ variable. You might explore $_ like this: try { $w = New-Object net.WebClient $d = $w.downloadString(‘http://foo’) } catch [Net.WebException] { $_ | fl * -Force } I think it … Read more