# How to get Out-GridView display to show from a GUI?

**URL:** <https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490>\
**Category:** PowerShell Help\
**Created:** [April 11, 2018, 9:45am UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490 "2018-04-11T09:45:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 11, 2018, 9:45am UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490/1 "2018-04-11T09:45:33Z")

</div>

I am working on putting together a PowerShell GUI for some Helpdesk folks at my work and what I want to happen is when a button is clicked, I want the Out-GridView to display with the results.

However, it is not working the way I had intended, but it works just fine when running from the PowerShell ISE.

I am assuming then that when running PowerShell code from a GUI, Windows Forms locks in any external processes extraneous to its control? Therefore, I need to use a Windows Forms toolbox object instead like a textbox, etc?

If this is the case, which Windows Forms object should I use that would be the closest thing to Out-GridView?

Thank you

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [April 11, 2018, 9:47am UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490/2 "2018-04-11T09:47:13Z")

</div>

You might share a relevant chunk of code; I’ve never had a problem invoking Out-GridView from a WinForms script. Rolling your own GridView is extremely nontrivial.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 11, 2018, 10:38am UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490/3 "2018-04-11T10:38:22Z")

</div>

```
$ListOutdatedSystems_Button_Click = {
	If ((Get-InstalledModule -Name 'ConfigurationManager') -eq $true)
{
	$SCCMDrive = (Get-PSDrive -PSProvider CMSite).Name
        
	Set-Location -Path "$($SCCMDrive):"

	Try
	{
		Get-CMCollectionMember -CollectionId 'PRI00408' | Select-Object -Property Name, UserName | Sort-Object -Property Name | Out-GridView -Title 'ENA Tool - SCCM O365 Deployment Notification' 
	}

	Catch
	{
		[System.Windows.MessageBox]::Show($_,'My GUI Tool',0,'Error')
	}
}

Else
{
		Try
		{
			Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1) -ErrorAction Stop

			Try
			{
				Get-InstalledModule -Name 'ConfigurationManager' -ErrorAction Stop
				
				$SCCMDrive = (Get-PSDrive -PSProvider CMSite).Name
        
				Set-Location -Path "$($SCCMDrive):"

				Try
				{
					Get-CMCollectionMember -CollectionId 'PRI00408' | Select-Object -Property Name, UserName | Sort-Object -Property Name | Out-GridView -Title 'My GUI Tool' 
				}

				Catch
				{
					[System.Windows.MessageBox]::Show($_,'My GUI Tool',0,'Error')
				}
			}
			
			Catch
			{
				[System.Windows.MessageBox]::Show($_,'My GUI Tool',0,'Error')
			}
		}

		Catch
		{
			[System.Windows.MessageBox]::Show($_,'My GUI Tool',0,'Error')
		}
	}

#endregion Step 3: List Outdated Systems
```

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [April 11, 2018, 10:41am UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490/4 "2018-04-11T10:41:24Z")

</div>

I don’t have SCCM so I can’t test this myself, but I’ve done exactly this with Get-Process and other “native” commands on more than one occasion. Worked fine.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 13, 2018, 8:04pm UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490/5 "2018-04-13T20:04:56Z")

</div>

Not sure what happened, but all of a sudden it’s working.

Something wonky, I suppose.

Thanks Don

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:35pm UTC](https://forums.powershell.org/t/how-to-get-out-gridview-display-to-show-from-a-gui/10490/6 "2024-05-16T20:35:57Z")

</div>


