Powershell Out-Gridview

Paul Schrader 1 Reputation point
2021-04-01T00:16:20.7+00:00

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 for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-04-01T04:49:13.027+00:00

    Hi,

    To the best of my knowledge, this cmdlet provides no parameter to set the column width.
    https://learn.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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.