PS C:\Users\ad_ctjares> Stop-Transcript -ErrorAction silentlycontinue
Transcription has not been started. Use the start-transcript command to start transcription.
Stop-Transcript : An error occurred stopping transcription: The console host is not currently transcribing.
At line:1 char:16
+ Stop-Transcript <<<< -ErrorAction silentlycontinue
+ CategoryInfo : InvalidOperation: (:) [Stop-Transcript], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.StopTranscriptCommand
该代码说明了一切。为什么当我指定-ErrorAction SilentlyContinue时仍然显示错误?
不知道,但Connect上有一个关于它的问题,以及一个解决方法:http://connect.microsoft.com/PowerShell/feedback/details/549321/start-stop-transcript-ignores-erroraction – Dogmang
谢谢 - 这导致我到这里:http://stackoverflow.com/questions/6307127/hiding-errors-when-using-get-adgroup,我发现我需要使用'try {} catch {}'因为'-ErrorAction'不影响终止错误 –