ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

Job reports of PowerShell commands wrap at 80 characters per line

book

Article ID: 88166

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

Error Message :
N/A

A Windows JOBS is used to execute PowerShell commands using the interpreter:
 

<Please see attached file for image>

0EMb0000001QsjG.png

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

<Please see attached file for image>

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.
 

<Please see attached file for image>

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.

 

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.

Environment

OS: Windows

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:

<Please see attached file for image>

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.

<Please see attached file for image>

0EMb0000001Qsju.png

 


Fix Status: No Fix

Fix Version(s):
N/A

Additional Information

Workaround :
N/A

Attachments

1558693359252000088166_sktwi1f5rjvs16m68.png get_app
1558693357496000088166_sktwi1f5rjvs16m67.png get_app
1558693355667000088166_sktwi1f5rjvs16m66.png get_app
1558693353798000088166_sktwi1f5rjvs16m65.png get_app
1558693351901000088166_sktwi1f5rjvs16m64.png get_app