Claus_Jambrich_5663

Job reports of PowerShell commands wrap at 80 characters per line

Discussion created by Claus_Jambrich_5663 on Apr 24, 2017
Execute a PowerShell command in a Windows Job:

0secifvrz00r.png

As an example, I use a simple Get-Content to show the content of a txt-file. The PowerShell command, executed on the command line, delivers a table and the lines are not wrapped:

2r4rllaprd3h.png

Executing the same command in a Windows JOBS, the results are wrapped at 80 characters as shown below:

sf1jlz3hpttg.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.

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:

bi1mdzq7gmwg.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 line:

$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 (in the example aboveabove) characters. The line length can be chosen as needed. The lines will no longer wrap at 80 characters:

hecpp3nn77pa.png

Outcomes