Product: PowerShell Universal
Version: 5.0.6
I am trying to do a bit of troubleshooting for my code, and I cant seem to figure out why one of my variables does not carry over into the -OnClick command for a New-UDCard.
$grpArray, $grpstr, $Cache, $Session = Invoke-PSUScript -Name 'RemoveSingleGroup.ps1' -newuser $NetID -Wait
#Show-UDToast -Message $Session[0] -Duration 5000
New-UDCard -Title "Select Groups to Remove User Access From:" -Content {
for($i=0; $i -lt $grpstr.count ;$i++) {
Show-UDToast -Message $Session[$i] -Duration 5000
New-UDButton -Text $grpArray[$i] -OnClick {
Show-UDToast -Message $Session[$i] -Duration 5000
$session is an array of strings that works in all of my Show-UDToast tests until I attempt to access it inside the New-UDButton I made. I have tried setting the index to 0 instead of $i, but I get the same results. Any insight into why the variable is not carrying on, and how to get it to would be appreciated.