pages/script-execute.ps1
New-UDPage -Url 'script-execute/:scriptId' -Endpoint { $Script = Get-UAScript -Id $ScriptId New-UDHeading -Text $Script.Name -Size 3 if ($Script.Parameters.Length -gt 0) { New-UDInput -Content { Get-UAScriptParameter -ScriptId $Script.Id | ForEach-Object { New-UDInputField -Name $Script.Name -Type textbox } } -Endpoint { $parameters = @{} Get-UAScriptParameter -ScriptId $Script.Id -ComputerName $ComputerName -AppToken $AppToken | ForEach-Object { $parameters[$Script.Name] = Get-Variable -Name $Script.Name -ValueOnly } Invoke-UAScript -Id $Script.Id @parameters -ComputerName $ComputerName -AppToken $AppToken | Out-Null New-UDInputAction -Content { New-UDHeading -Text "Running script..." } } } else { New-UDButton -Text "Run" -Icon 'play' -OnClick { Invoke-UAScript -Id $Script.Id Set-UDElement -Id 'output' -Content { New-UDHeading -Text "Running script..." } } New-UDElement -Tag 'div' -Content {} -Id 'output' } } |