In week 1 of the new item Tip of the Week, I will discuss the option to add more PowerShell output variables to multiple Ivanti Automation parameters.
A video recording can be found below the blog and shows the full process described in this blog.
With Ivanti Automation a task to execute PowerShell scripts is available. The task provides an option to add the output of a PowerShell script into a variable. This option can be found in the Settings tab of the Execute PowerShell task.
A predefined parameter can be selected or a new parameter can be created. This option only supports one output but what if we have a script that gives multiple outputs which need to be added to different Ivanti Automation parameters?
Below is a simple PowerShell script that searches for the FullName of a user and in which OU (Organizational Unit) the user resides.
$UserInfo = Get-ADUser -Identity $[username] -Properties Name | Select-Object UserPrincipalName, Name $Global:UPN = $UserInfo.UserPrincipalName $Global:FullName = $UserInfo.Name
Steps creating the Ivanti Automation Module:
- Create a new Module
- Select the option Add
- Search for the Windows PowerShell Script (execute)
- Add a PowerShell in the Script tab
- For this specific script create 3 parameters (username, UPN and FullName). Check the screenshots below how to configure the parameters
UPN and FullName parameters (because we will request the values with the PS Script the When scheduling Job input must be disabled)
The script contains 2 lines a starting with $Global:
$Global:<Automation Parameter> = <PS variable>
With the Global option, multiple script outputs can be added to multiple Automation parameters.
After scheduling and executing the module the result is shown in the screenshot below:
Check the recording how to build the PowerShell Variables Module.