Powershell 脚本错误日志

try{
Get-AD *>&1
}
catch{
Get-Date | Add-Content C:ScriptErrors.txt
$_ | Add-Content C:ScriptErrors.txt
"----------------------------------------------------------------------------------------
" | Add-Content C:ScriptErrors.txt
}

原文地址:https://www.cnblogs.com/jpinsz/p/13452269.html