Powershell - Format-Table output from two cmdlets

ST1285 11 Reputation points
2023-02-13T09:54:06.52+00:00

Hi,

I'm trying to get data from two different cmdlets into the same format-table output. Here is what I'm trying to run (SCOM-specific):

$SQLWindowsClustersMMState = Get-SCOMClass -Name 'Microsoft.Windows.Cluster' | Get-SCOMClassInstance | Where {$_.Name -like "SQL"}

Variable output:

HealthState InMaintenanceMode DisplayName
Uninitialized True SQL02

The above gives a DisplayName property, which I then want to carry into the ft at the end of the below, as the Get-SCOMMaintenanceMode cmdlet only gives a MonitoringObjectId GUID-style field and no Name or DisplayName property:

$SQLWindowsClustersMMState| Where {$SQLWindowsClustersMMState.InMaintenanceMode -eq $true}|Get-SCOMMaintenanceMode|ft DisplayName,ScheduledEndTime

DisplayName ScheduledEndTime
13/02/2023 11:57:26

I've tried ft $SQLWindowsClustersMMState.DisplayName,ScheduledEndTime, which puts the server DisplayName into the Header:

SQL02 ScheduledEndTime
13/02/2023 11:57:26

I also tried ft MonitoringObjectId,@{Label="DisplayName";Expression=$SQLWindowsClustersMMState.DisplayName},ScheduledEndTime, with no luck:

MonitoringObjectId DisplayName ScheduledEndTime

------------------ ----------- ----------------

d45f0eb8-78f8-19e4-62fa-c3b1174efb92 13/02/2023 11:57:26

What am I doing wrong?

System Center Operations Manager
System Center Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,603 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-02-14T16:39:14.6566667+00:00

    Hi,

    Thank you for posting your query.

    Kindly follow the steps provided below to resolve your query.

    PowerShell has a set of cmdlets that allow you to control how properties are displayed for particular objects. The names of all the cmdlets begin with the verb Format. They let you select which properties you want to show

    Go to this link for your reference and additional troubleshooting procedures https://learn.microsoft.com/en-us/powershell/scripting/samples/using-format-commands-to-change-output-view

    If the answer is helpful kindly click "ACCEPT AS ANSWER" and up vote it.

    0 comments No comments

  2. Limitless Technology 44,751 Reputation points
    2023-02-14T16:39:24.4366667+00:00

    Double post

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.