Getting the output of a UAScript in a form

Hello,

I’ve been racking my brain around trying to get the output of a variable in my script to a form. If someone could show me the light that would be awesome. I have been able to get the pipeline output but the standard output seems to elude me. I don’t want to share the entire script as it’s making an API call to our company with sensitive information but I have the variables and a partial of the output.

Variables

$Site
$firstName
$lastName
$displayName
$userName
$email
$Department
$jobTitle
$employeeType
$Manager

Output

Sep 14, 2021 12:01 AM Peabody
Sep 14, 2021 12:01 AM Jeremy
Sep 14, 2021 12:01 AM Jenkins
Sep 14, 2021 12:01 AM Jeremy Jenkins
Sep 14, 2021 12:01 AM Jeremy.Jenkins
Sep 14, 2021 12:01 AM Jeremy.Jenkins@email.com
Sep 14, 2021 12:01 AM Information Technology
Sep 14, 2021 12:01 AM Help Desk Analyst
Sep 14, 2021 12:01 AM Indirect
Sep 14, 2021 12:01 AM 28

In my dashboard I have…

Invoke-UAScript -Name ‘OnboardingRetrevial.ps1’ -param $ticketInput | Wait-UAJob
$onboardingJob = Get-UAScript -Name ‘OnboardingRetrevial.ps1’ | Get-UAJob OrderDirection Descending -First 1

I thought Get-UAJobOutput -JobId $onboardingJob would have some way for me to select a variable but I can’t find it.

Thank you!

Product: PowerShell Universal
Version: 1.4.6

You could adjust your script to return a hashtable and then you use the pipeline output to grab only the property you want.

@{ 
Site = $Site
FirstName = $firstName
LastName = $lastName
DisplayName = $displayName
UserName = $userName
# ...
}

And then with the pipeline output:

Invoke-UAScript -Name ‘OnboardingRetrevial.ps1’ -param $ticketInput | Wait-UAJob
$onboardingJob = Get-UAScript -Name ‘OnboardingRetrevial.ps1’ | Get-UAJob OrderDirection Descending -First 1
$Output = Get-UAJobPipelineOutput -JobId $onBoardingJob
$Output.FirstName

That works for me thank you!

So I adjusted my script as you advised and the pipeline output is just “Object”

image

$Site = $incidentResults.custom_fields.1341

$Site = $Site.psobject.Properties.value

$firstName = $incidentResults.custom_fields.1396

$lastName = $incidentResults.custom_fields.1398

$displayName = $firstName + " " + $lastName

$userName = $firstName + “.” + $lastName

$email = $userName + “@paradigmprecision.com

$Department = $incidentResults.custom_fields.1351

$jobTitle = $incidentResults.custom_fields.1392

$employeeType = $incidentResults.custom_fields.1357

$employeeType = $employeeType.psobject.Properties.value

$Manager = $incidentResults.custom_fields.1340 | Write-Output

@{

Site = $Site

FirstName = $firstName

LastName = $lastName

DisplayName = $displayName

UserName = $userName

Email = $email

Department = $Department

JobTitle = $jobTitle

EmployeeType = $employeeType

Manager = $Manager

}

I think this is fixed in 2.3, but try this:

[PSCustomObject]@{

Site = $Site

FirstName = $firstName

LastName = $lastName

DisplayName = $displayName

UserName = $userName

Email = $email

Department = $Department

JobTitle = $jobTitle

EmployeeType = $employeeType

Manager = $Manager

}

The data is still stored as a hashtable but the display of the hashtable is messed up.

That did it, thank you!

Yeah so strange behavior here for some reason that still wont return anything but if the other pipeline output will work. Is there any chance you could do a zoom call? I can’t really explain it over text. It’s strange.

The top objects work (the numbers) but second set does not.

Code

$incidentResults.custom_fields
[PSCustomObject]@{
Site = $Site
FirstName = $firstName
LastName = $lastName
DisplayName = $displayName
UserName = $userName
Email = $email
Department = $Department
JobTitle = $jobTitle
EmployeeType = $employeeType
Manager = $Manager
}

Wanted to pop back in here and say the issue is on my code and Adam’s solution is working. Thanks again!

1 Like