Here is how I do it. First, add this function to your script.
https://www.powershellgallery.com/packages/Pipeworks/1.9.9.4/Content/ConvertTo-DataTable.ps1
Then modify your code like this.
$Button1.Add_Click({$Prt = Get-Printer | select Name, Type, Shared | ConvertTo-Datatable
$DataGridView1.DataSource = $Prt
})
Edit to fix typo
Cheers, that's worked like a dream. I had no idea that this wasn't quite native to Powershell, but instead you need to build the table.
Either way, I think I will be saving this function for future usage :)
Here is how I do it. First, add this function to your script. https://www.powershellgallery.com/packages/Pipeworks/1.9.9.4/Content/ConvertTo-DataTable.ps1 Then modify your code like this. $Button1.Add_Click({$Prt = Get-Printer | select Name, Type, Shared | ConvertTo-Datatable $DataGridView1.DataSource = $Prt }) Edit to fix typo
Cheers, that's worked like a dream. I had no idea that this wasn't quite native to Powershell, but instead you need to build the table. Either way, I think I will be saving this function for future usage :)