这是PowerShell 2.0中的try catch
$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")
}
}
但是我想要做的是类似于c#中的东西
catch( WebException ex)
{
Log(ex.ToString());
}
这个是可能的吗?
https://stackoverflow.com/questions/2182666
复制相似问题