This is the try catch
in PowerShell 2.0
$urls = "http://www.google.com", "http://none.greenjump.nl", "http://www.nu.nl"
$wc = New-Object System.Net.WebClient
foreach($url in $urls)
{
try
{
$url
$result=$wc.DownloadString($url)
}
catch [System.Net.WebException]
{
[void]$fails.Add("url webfailed $url")
}
}
but what I want to do is something like in c#
catch( WebException ex)
{
Log(ex.ToString());
}
Is this possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…