简体   繁体   中英

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

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.

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM