我正在尝试测试运行Get-SBFarmStatus
的结果是否存在故障。命令的输出看起来像一个格式良好的PSObject,但它是某种奇怪的MS格式字符串:
> $result
HostId HostName ServiceName Status
------ -------- ----------- ------
1 NVSDRELSBS12330.discoverready.local Service Bus Gateway Running
1 NVSDRELSBS12330.discoverready.local Service Bus Message Broker Running
1 NVSDRELSBS12330.discoverready.local Service Bus Resource Provider Running
1 NVSDRELSBS12330.discoverready.local Service Bus VSS Running
1 NVSDRELSBS12330.discoverready.local FabricHostSvc Running
> $result.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
> $result.Status
# <-- nothing returned
> $result | select *
ClassId2e4f51ef21dd47e99d3c952918aff9cd : 033ecb2bc07a4d43b5ef94ed5a35d280
pageHeaderEntry :
pageFooterEntry :
autosizeInfo :
shapeInfo : Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo
groupingEntry :
ClassId2e4f51ef21dd47e99d3c952918aff9cd : 9e210fe47d09416682b841769c78b8a3
shapeInfo :
groupingEntry :
ClassId2e4f51ef21dd47e99d3c952918aff9cd : 27c87ef9bbda4f709f6b4002fa4af63c
formatEntryInfo : Microsoft.PowerShell.Commands.Internal.Format.TableRowEntry
outOfBand : False
writeStream : None
ClassId2e4f51ef21dd47e99d3c952918aff9cd : 27c87ef9bbda4f709f6b4002fa4af63c
formatEntryInfo : Microsoft.PowerShell.Commands.Internal.Format.TableRowEntry
outOfBand : False
writeStream : None
ClassId2e4f51ef21dd47e99d3c952918aff9cd : 27c87ef9bbda4f709f6b4002fa4af63c
formatEntryInfo : Microsoft.PowerShell.Commands.Internal.Format.TableRowEntry
outOfBand : False
writeStream : None
etc etc
如何将这些数据解析为易于访问的对象?
根据输出中Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo
的存在,我猜$result
由Format-*
输出填充。删除任何Format-*
命令,因为它们仅用于主机输出。