Job reports of PowerShell commands wrap at 80 characters per line

Document ID : KB000088166
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
Error Message :
N/A

A Windows JOBS is used to execute PowerShell commands using the interpreter:
 
0EMb0000001QsjG.png

The PowerShell command, executed on the command line, delivers a table and the lines are not wrapped:

0EMb0000001QsjL.png

In the example, a simple Get-Content is used to show the content of a txt-file. Executing the same command in a Windows JOBS, the results are wrapped at 80 characters as shown below.
 
0EMb0000001QsjQ.png

This behavior cannot be changed on Automic's side and is not a defect of our product. By default, PowerShell sessions are opened with a line length of 80 characters and everything longer is wrapped.

 
Environment:
OS: Windows
Cause:
Cause type:
By design
Root Cause: The default line length for PowerShell is 80 characters and Automic calls PowerSehll with the default settings. If these settings do not fit the needs, it has to be changed on PowerShell side.
Resolution:
To overcome this, a PowerShell profile-file can be created by executing the following command in a Windows JOBS on the same Agent and with the same Login-User as the JOBS with the previous PowerSehll command:
 
New-Item -path $profile -type file –force

The result in the job report looks like this:
0EMb0000001Qsja.png

The command creates a profile-file that will be used from now on for this user (sup in the example), and the output shows the path and the filename of this file. Open this file in a text-editor and insert the following lines:

$rawUI = $Host.UI.RawUI
$oldSize = $rawUI.BufferSize
$typeName = $oldSize.GetType( ).FullName
$newSize = New-Object $typeName (200, $oldSize.Height)
$rawUI.BufferSize = $newSize

These script-lines set the line length of a PowerShell session for this user to 200 (marked in red above) characters. The line length can be chosen as needed. The lines will no longer wrap at 80 characters.
0EMb0000001Qsju.png

 


Fix Status: No Fix

Fix Version(s):
N/A
Additional Information:
Workaround :
N/A