Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out-GridView in PowerShell: How to change the initial size of the window?

I often work with the useful function Out-GridView in PowerShell. Sometimes I only have little data to show in the GridView but it opens in a very big window every time. Is there a possibility to change the initial size of the GridView window? A table with 3 columns and 4 rows should not be displayed in a window that is nearly fullscreen on a 1920x1080 display ...


2 Answers

PowerShell is a scripting language, not really a GUI language. It's possible to create GUI's with the help of tools like SAPIEN PowerShell Studio and others, by using Winforms or wpf.

In short, what you want is not possible I'm afraid, as there's no parameter for it.

like image 81
DarkLite1 Avatar answered Oct 22 '25 04:10

DarkLite1


I ran into the same issue and ended up using this "workaround" that autosizes.

$null = [System.Reflection.Assembly]::LoadFile('C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\Microsoft.VisualBasic.dll')

$words = @"
    Line 1
    This is the line after line 1
    The third line contains the number 5.
"@

#if "words" is an array, change below to ($words | out-string)

[Microsoft.VisualBasic.Interaction]::MsgBox(($words),0, "Title")
like image 20
ujoshi Avatar answered Oct 22 '25 03:10

ujoshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!