PowerShell

Modified on Fri, 10 May at 10:46 AM

TABLE OF CONTENTS


Introduction to Question Type

With this Question Type, you can use a PowerShell Script to gain any information and present it in au2mator. You can return a single string or a table of results for the user to choose from.



Settings

  • Prepop Title
    • The custom Title is shown at the front when a User is executing the PowerShell as the Title of the Prepop Table.


  • Prepop Description
    • The custom Description is shown at the front when a User executes the PowerShell as a Description of the Prepop Table.
Use custom Title and Description to describe the Content in the Prepop Table to the User



  • Prepop Table Desing
    • When you select "Prepop Table" on the "Show Result as" Setting, you can decide the Style of the Table Design

  • PowerShell Script
    • The PowerShell Script you want to execute here. For more details, see the next topic (Details)
Make sure you configured the PowerShell Automation before using the PowerShell Question Type: PowerShell


  • Is PowerShell Result Editable
    • Choose if the User can edit the PowerShell Text Box Result or not


  • Selection Type
    • Choose "Single" or "Multiple" to configure the possible selection Type for the User. Multiple values are joined with ";" and sent to Automation.


  • Visibility
See our How to configure dynamic Forms for more Details



Details

On our GitHub Repository, you can see some PowerShell Question Type Examples


GitHub - au2mator/au2mator-PS-Templates


Input

You can use already answered Questions or our built-in Parameters in the PowerShell Question. All information is transferred to the parameter "au2matorhook"

param ($au2matorhook)
$jsondata = $au2matorhook | ConvertFrom-Json

You then can use the "$jsondata" and dot source parameters to get the Values. 

Our built-in Parameters are used as follows

$InitiatedBy=$jsondata.InitiatedBy
$Service=$jsondata.Service
$TargetUserId=$jsondata.TargetUserId

The Custom Input Parameters depend on the original unique key in the Autoamtiion itself. Here we use the internal Key, not the Configure Question. 


So, for example, if you have a Question with the internal Name "c_User" you can get the Value with "$jsondata.CUser"



Return

Depending on the Return Type, we directly write the String in the Question or provide a Prepop Table to select a Value.


A Prepop Table will presented when an Array is returned. We recommend to build a PSObject and return that array


$ReturnArray = @()

foreach ($R in $Result.value) {
    $Temp = New-Object -TypeName PSObject

    $Temp | Add-Member -MemberType NoteProperty -Name Name -Value $NiceName
    $Temp | Add-Member -MemberType NoteProperty -Name License -Value $License
    $Temp | Add-Member -MemberType NoteProperty -Name Used -Value $Units
    $Temp | Add-Member -MemberType NoteProperty -Name Available -Value $Available
    $Temp | Add-Member -MemberType NoteProperty -Name State -Value $State
    $ReturnArray += $Temp
}

return $ReturnArray








Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article