我从 Powrshell 调用 rabbitmqctl:
$out = (& $path ($arguments -split " ") )
Write-Host $out
使用正确的路径,输出会显示成功消息:
Clearing policy "<policyname>" on vhost "<vhost>" ...
如果路径不正确,我会遇到异常:
....
+ CategoryInfo : NotSpecified: (Error::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Parameter does not exist
消息Clearing policy
丢失。停止执行时,$_.Exception.Message 为空。
try {
$ErrorActionPreference = 'Stop'
...
}
catch {
Write-Warning $_.Exception.Message
}
有没有办法同时获取Clearing policy
消息和最后一行Parameter does not exist
?