Flow Designer Powershell Action - Pass Output into Action from PS script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2020 04:05 PM
I'm trying to capture the output in the flow designer "output" variable within my Powershell script. Example
if($action -eq "add"){
Write-Output "Adding Mailbox Permission"
try{
Add-MailboxPermission -Identity $mailbox -user $upn -AccessRights fullaccess -ErrorAction Stop -Confirm:$False
Write-host "Added Full Access"
Add-RecipientPermission -Identity $mailbox -AccessRights sendas -Trustee $upn -ErrorAction Stop -Confirm:$False
SNCLog-DebugInfo "SUCCESS: Added $upn to $mailbox, $task"
Write-Output "Success"
} catch{
#$returnObj.Add("Error", $_)
Write-Output "Error"
}
As you can see, I would like to find the syntax to associate the "Error" or "Success" with a variable within flow designer.
I'm able to access my input variables fine, like so:
$userEmail=$env:SNC_userEmail
Anyone have any ideas, or the proper syntax?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2020 05:27 AM
From the few that I have built the PowerShell step has an output that is what ever was last output by the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2020 09:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2020 10:03 AM
Look at using " | Out-Null" at the end of commands that are putting out things that you do not want outputting to the screen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2020 07:59 AM
I was able to get it working somewhat.. I ended up exporting the data to CSV and then uploading that to a SFTP server, and reimporting back into ServiceNow using a scheduled data source to make the most use of OOB functions that I can.