Applications Systems

Display of PowerShell output does not match console output

When using PowerShell in Server Configuration Monitor (SCM), the display of PowerShell output may be wrapped or may not match the console output. This KB article offers recommendations on how to resolve these issues.

First published date

2/21/2019 8:33 PM

Last published date

2/21/2019 8:33 PM

Overview

When using PowerShell in Server Configuration Monitor (SCM), the display of PowerShell output may be wrapped or may not match the console output. This KB article provides recommendations on how to resolve these issues.

Product section

Server Configuration Monitor

Cause

To preserve as much data from script output as possible, SCM is set to automatically change console width to 4,096 characters. Due to this default width, the output from commandlets may sometimes be truncated. For instance, PowerShell 2, 3, and 4 use the entire width of the console for Format-Table when the -Property parameter is used.

Resolution


If your PowerShell output contains extra white space or wraps unexpectedly, causing poor readability (as shown above), take the following steps:
  1. Add -AutoSize switch to all Format-Table calls (for instance, Get-Service | Format-Table -Property ServiceName, DisplayName, StartType -AutoSize).
The -AutoSize also resolves the issue of columns sometimes being too narrow to accommodate all data.
  1. Use -Wrap to wrap text of last column if the console is still too narrow.