我想要访问与Powershell打印的错误记录相同的消息。
示例:
这是异常消息,位于C:\Documents and Settings\BillBillington\Desktop\psTest\exThrower.ps1:1字符:6
throw <<<< (New-Object ArgumentException("This is the exception")); CategoryInfo : OperationStopped: (:) [], ArgumentException FullyQualifiedErrorId : This is the exception
当我通过$Error[0]获取最后一个ErrorRecord时,似乎无法简单地获取这些信息。
我在社区扩展中找到了一个名为'Resolve-Error'的函数here,它大致符合我的需求,但会打印出一大堆我不需要的半格式化列表,我还需要将其剥离。
有没有办法访问Powershell使用的消息,或者如果失败的话,有没有更简单的方法来获取我关心的值的哈希,以便我可以按照自己选择的格式将它们放入字符串中?
示例:
这是异常消息,位于C:\Documents and Settings\BillBillington\Desktop\psTest\exThrower.ps1:1字符:6
throw <<<< (New-Object ArgumentException("This is the exception")); CategoryInfo : OperationStopped: (:) [], ArgumentException FullyQualifiedErrorId : This is the exception
当我通过$Error[0]获取最后一个ErrorRecord时,似乎无法简单地获取这些信息。
我在社区扩展中找到了一个名为'Resolve-Error'的函数here,它大致符合我的需求,但会打印出一大堆我不需要的半格式化列表,我还需要将其剥离。
有没有办法访问Powershell使用的消息,或者如果失败的话,有没有更简单的方法来获取我关心的值的哈希,以便我可以按照自己选择的格式将它们放入字符串中?