Product: PowerShell Universal
Version: 5.5.1
Hi, after working on some small projects involving the further processing of outputs into variables, I wanted to share my experiences. I would like to use this thread as a basis so that everyone can make their experiences visible to others. It can sometimes be a bit tricky to apply the correct variable.
Working with New-UDForm: $formResult= ($EventData.form1Textbox)
New-UDForm -Id 'form1' -Content {
New-UDTextbox -Id 'form1Textbox' -HelperText 'Some input value!' -Autofocus
} -OnSubmit {
$formResult= ($EventData.form1Textbox)
Show-UDToast -Message "$formResult" -Duration 6000
}
Working with New-UDUpload: $Session:CSV = Import-CSV $Body.FileName
New-UDGrid -Item -ExtraSmallSize 2 -Content {
New-UDUpload -Text 'Upload CSV' -Icon (new-UDIcon -Icon file-import -Size lg) -OnUpload {
$Session:CSV = Import-CSV $Body.FileName -Delimiter ";"
Sync-UDElement -Id 'CSV'
} -HideUploadedFileName
}
Working with Invoke-PSUScript (IIS): $Session:Testresult = invoke-PSUScript
It is important that the mentioned script includes a return $variable
, so that the output can be further processed in the Invoke-PSUScript
.
New-UDButton -Id 'btnRunScript' -Text "Get value" -OnClick {
$Session:Testresult = invoke-PSUScript -name "Test.ps1" -ComputerName 'PSU hostname' -AppToken "Apptokenkey" -Wait
Sync-UDElement -Id 'testTable'
} -ShowLoading