question

PaulSchrader-3898 avatar image
0 Votes"
PaulSchrader-3898 asked IanXue-MSFT answered

Powershell Out-Gridview

Hello,

When using the below command how do I set the column sizes to a desired length

Get-Process | ? {$.SI -eq (Get-Process -PID $PID).SessionId}| select ProcessName,Path ,Description,StartTime |Out-GridView -Title ' Select the Items you want to Terminate. Hold CTRL to select multiple processes.' -PassThru | Foreach{Stop-Process -id $.Id}

The Columns get truncated and each time it runs I have to manually size the columns

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

Hi,

To the best of my knowledge, this cmdlet provides no parameter to set the column width.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-gridview

And the Id property has to be selected or $_.Id in the foreach loop is null.

 Get-Process | ? {$_.SI -eq (Get-Process -PID $PID).SessionId}| select Id,ProcessName,Path ,Description,StartTime |Out-GridView -Title ' Select the Items you want to Terminate. Hold CTRL to select multiple processes.' -PassThru | Foreach{Stop-Process -id $_.Id}

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.