PS Custom Object - Format Output

Copper Contributor

Hello,

 

I have the following code:

 

$dbs = Get-AzSqlDatabase -ResourceGroupName $SQLResourceGroup -ServerName $ServerName

$results = foreach ($db in $dbs.DatabaseName)
{
    $dbAudit = Get-AzSqlDatabaseAudit -ResourceGroupName $SQLResourceGroup -ServerName $ServerName -DatabaseName $db

    [PSCustomObject]@{
                             Database = $dbAudit.DatabaseName
                             Storage  = $dbAudit.BlobStorageTargetState
                            }


}
$results | Format-Table -Property @{Expression={$_.DatabaseName};Label="Display Name";width=35}, `
                                  @{Expression={$_.BlobStorageTargetState};Label="Login Name";width=40}

 

The script originally worked before I added the FT function.  Now the display is blank as shown below:

 

Display Name Login Name
------------ ----------
                       
                       
                       

If I remove the FT function it will display in key/value pairs.  I'd like for it to be displayed in columnar format.

 

Any ideas?

 

Thanks,

Frank

1 Reply
You could try outputting your data as [string]::Format("{0} `t `t {1}", $variable1, variable2) . the `t is tabbing between the two?