问题描述
我正在尝试处理Power-shell脚本的异常。
try
{
Invoke-ASCmd -Server:va33dwpsas001\SAS0 -InputFile:"D:\\Scripts\\ProcessFull_Test.xmla" -TraceFile:"D:\\Logs\\ProcessFull.log"
}
Catch
{
$ErrorMessage = $_.Exception
write-host "Caught an exception:"
write-host "Exception type: $($_.Exception.GetType().FullName)"
write-host "Exception message: $($_.Exception.Message)"
write-host "Error: " $_.Exception
}
但是使用上面的代码,我只能捕获System.UnauthorizedAccessException异常
<return xmlns="urn:schemas-microsoft-com:xml-analysis"><root xmlns="urn:schemas-microsoft-com:xml-analysis:empty"></root></return>
Caught an exception:
Exception type: System.UnauthorizedAccessException
Exception message: Access to the path 'D:\\Scripts\\ProcessFull_Test.xmla' is denied.
Error: System.UnauthorizedAccessException: Access to the path 'D:\\Logs\\ProcessFull.log' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode,String maybeFullPath)
at System.IO.FileStream.Init(String path,FileMode mode,FileAccess access,Int32 rights,Boolean useRights,FileShare share,Int32 bufferSize,FileOptions options,Security_ATTRIBUTES secAttrs,String
msgPath,Boolean bFromProxy,Boolean useLongPath,Boolean checkHost)
at System.IO.FileStream..ctor(String path,String msgPath,Boolean chec
kHost)
但不是
Invoke-ASCmd : The 'SAS0' instance was not found on the 'va33dwpsas001' server.
At C:\Users\AG80238\Desktop\Logs\Test.ps1:8 char:1
+ Invoke-ASCmd -Server:va33dwpsas001\SAS0 -InputFile:"D:\\Scripts\\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Invoke-ASCmd],ConnectionException
+ FullyQualifiedErrorId : ExecutionFailed,Microsoft.analysisservices.PowerShell.Cmdlets.ExecuteScriptCommand
Invoke-ASCmd : InputFile "\\va33dwpsas001\\Scripts\\RFR_LOBs_May_xmla\\Commercial\\RFRCommercialProcessFullBudget1_Test.xmla" not found
At C:\Users\AG80238\Desktop\Logs\Test.ps1:8 char:1
+ Invoke-ASCmd -Server:va33dwpsas001\SAS0 -InputFile:"\\va33dwpsas001\\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-ASCmd],FileNotFoundException
+ FullyQualifiedErrorId : DataValidation,Microsoft.analysisservices.PowerShell.Cmdlets.ExecuteScriptCommand
关于如何捕获上述异常的任何建议。
先谢谢了。 莫汉五世。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)