Using PowerShell Studio 2015 snippet sample

In my previous blog I show how to integrate a custom function called “RefreshDataGrid1” which is used to populate the DataGrid.  Now, SAPIEN PowerShell Studio does provide a Snippet code called “ConvertTo-DataTable” will convert your PSObject to a Data Table type which can be load into the DataGrid component. Thanks to June Blender (SAPIEN Technology Evangelist) for showing me the ” ConvertTo-DataTable” function.


This function can be found in the Snippet panel just below the WMI folder.


So, changes can be made to the existing TestDataGrid01 solution: 1. Removing the “RefreshDataGrid1” function code and from Button_Click event. 2. From the “Snippet” panel, Drag/Drop the “ConvertTo DataTable” code into the Script pane. 3. finally add the code to use the function in the “Button_Click” event.


So, adding the following two line of code will get the data populated into the DataGrid component:

[sourcecode language=”powershell”]
$table = ConvertTo-DataTable -InputObject $MyGridObject
$datagrid1.DataSource = $table;


The use of Snippet code can help cut down your PowerShell Coding time.



Please, take the time to learn and understand this tool.  It’s full of interesting features.  Don’t forget to check SAPIEN Blog site at: