bugy / script-server

Web UI for your scripts with execution management
Other
1.61k stars 249 forks source link

WindowsSize with PowerShell 7.0 on Linux #435

Closed ashishsharma-git closed 3 years ago

ashishsharma-git commented 3 years ago

I have installed PowerShell 7.0 on Ubuntu and running PowerShell scripts. The script returns some data in tabular format, basically doing a Format-Table -Autosize for the resultant data. When I run the script directly the complete table is visible, however when I run it through Script Server the output width is limited to 80 as the Shell / Console initiated appears to be limited to 80x40.

Here are the shell / console size details I get for executions from script server :

ForegroundColor : -1 BackgroundColor : -1 CursorPosition : 0,0 WindowPosition : 0,0 CursorSize : 100 BufferSize : 80,40 WindowSize : 80,40 MaxWindowSize : 80,40 MaxPhysicalWindowSize : 80,40 KeyAvailable : True WindowTitle :

I've tried changing powershell console size with following command :

pwsh -command [console]::windowwidth=120; [console]::windowheight=30; [console]::bufferwidth=[console]::windowwidth]

But this doesn't work and I receive error :

SetValueInvocationException: Exception setting "windowwidth": "Operation is not supported on this platform." SetValueInvocationException: Exception setting "windowheight": "Operation is not supported on this platform." SetValueInvocationException: Exception setting "bufferwidth": "Operation is not supported on this platform."

Where is this being restricted and how to allow for larger width to show data ?

bugy commented 3 years ago

Hi @ashishsharma-git to be honest I don't know much about Powershell and nobody reported this problem before. Could you try to set the console size this way? https://ss64.com/ps/syntax-consolesize.html

bugy commented 3 years ago

One more possible solution https://www.nsoftware.com/kb/articles/powershell-server-changing-terminal-width.rst

ashishsharma-git commented 3 years ago

Hey @bugy Turns out it was Format-Table which was messing things up and I was looking in the wrong direction :)

Stumbled upon https://poshoholic.com/2010/11/11/powershell-quick-tip-creating-wide-tables-with-powershell/

Changing "Format-Table -Autosize" to "Format-Table -Autosize | Out-String -Width 4096" did the trick.

Thanks for your great work and help.

bugy commented 3 years ago

Cool, I'm happy it worked for you