【发布时间】:2013-06-20 13:36:37
【问题描述】:
我想将 PSObject 数组格式化为表格,我的代码是:
$object = @()
Foreach ($Alarm in Get-AlarmDefinition) {
Foreach ($AlarmAction in Get-AlarmAction -AlarmDefinition $Alarm) {
$obj = New-Object PSObject -property @{Definition = $Alarm.Name; Action =""; GY=""; YR=""; RY=""; YG=""}
Foreach ($AlarmActionTrigger in Get-AlarmActionTrigger -AlarmAction $AlarmAction) {
$obj.Action = $AlarmAction.ActionType
If ($AlarmActionTrigger.StartStatus -eq "Green") {
$obj.GY = $AlarmActionTrigger.Repeat
} Else {
If($AlarmActionTrigger.StartStatus -eq "Red") {
$obj.RY = $AlarmActionTrigger.Repeat
} Else {
If ($AlarmActionTrigger.EndStatus -eq "Green") {
$obj.YG = $AlarmActionTrigger.Repeat
} Else {
$obj.YR = $AlarmActionTrigger.Repeat
}
}
}
}
$object += $obj
}
}
$object | Format-Table Definition, Action,GY,YR,RY,YG -auto
但是返回这个错误:
ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
有人可以帮忙吗? TNX
【问题讨论】:
-
将管道移至格式表后会得到什么?
标签: powershell powercli