My best guess is this has something to do with the default output methods used in the Powershell console, but I am at a wall...
I am working on a script that contains a data table of default values found for configuration options in a SQL Server instance. I then have a function that goes and pulls the current in use values of those same configuration options.
I want to output two sets of information from this function: (1) filters specific information out of the current values itself and (2) filters specific information comparing the default values to the current values. So it would look something similar to this (leaving out the data table stuff):
$var1 = $current | where {my filters} |
Select @{label='name';Expression{stuff}},
@{label='value_in_use';Expression{stuff}},
@{label='value';Expression{stuff}}
$var2 = foreach ($o in $tblDefault) {
$current | where {my filters} |
Select @{label='name';Expression{stuff}},
@{label='value_in_use';Expression{stuff}},
@{label='default';Expression{stuff}}
Write-Host "This is a message"
$var1
Write-Host "This is a message"
$var2
}
My issue is with the output of the two variables.
- The third column for
$var2, "default", is not showing. - As well, the output shows only the column headings at the top of the output for
$var1.
Commenting out the first variable call this is the output that I should see for the second variable:
PowerShell does not even appear to see the additional columns from the second variable, when calling them both. I can do a Get-Memberon the function and it shows the property names only for the first variable.
What am I supposed to do in order to force this into separate objects (meaning column headings for both sets?
Just pasting this together with MSPaint this is the output I expected, and would like:
