Pages / Table : pass argument from line to a script


I’m new to the PowerShell Universal and digging around a bit. I’m stuck a single step that I do not sort out by myself: I have created a test page which display a table containing custom columns (obtains from a script). The last column is a button that should run a script which will toast the value contains in a specific column for the selected line. I have tried to set a custom parameter:

name is the name of the parameter from the called script (i.e. -MyVar)
value is the inputObject column expected ($inputObject.samaccountname)

As it was not working, I have changed my approach and set the parameter input in my script to catch whatever is sent, the then script send $inputObject. But again, not working (the object is null).

I do not understand how this should effectively works and do not found any tips in the documentation (or missed it).

Could someone provide me a quick step to use value from table when calling a script through a button ?


Product: PowerShell Universal
Version: 4.2.13

You should use the $EventData variable which will contain a property for each of your table columns.

Below is an extract of some code I use to interact with the TeamViewer API using data from the ‘ActionID’ column of the table while also showing a toast containing data from the ‘Alias’ column.

The button is rendered in the same row as the data within the table, so each row has its own button.

Hopefully that should get you on your way.

New-UDButton -Text "Yes" -OnClick { 
    Show-UDToast -BackgroundColor "#c6e0b4" -Message "Requesting deletion of $($EventData.Alias) from Team Viewer server" -Duration 10000 -Position bottomRight -Icon check-circle -MessageSize 16
    Invoke-RestMethod -Uri "$($EventData.ActionID)" -Method Delete -Headers $Header


Thanks, I’ll get a try on this :wink: