Powershell activity.output empty when running from script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2015 08:15 PM
I am attempting to run a Powershell script and push stdout to activity.output. I have verified when writing the script that it writes to stdout, but when I run the script from a workflow activity.output returns blank. If I copy this script in as a command in the Run Powershell activity it works just fine. Any ideas on why the script itself wouldn't be pushing to stdout although I see it that way when running it manually on the server? When running from a script does it store output to a different variable? Or is there something I need to do in my script for SNOW to see the output?
Thanks in advance.
- Labels:
-
Orchestration (ITOM)
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 11:42 AM
Not knowing how you have coded things I will start at normal handling and work toward JSON handling. 🙂
So what are you returning in your result that requires json? Looks like it might be a list.
Usually I return my results via Write-Host. This drops the result into the <output> tag within the XML returned on the ECC Queue. This in turn is translated to the output object in the Workflow Powershell Activity Sensor Script which can be obtained with code on line one; something like this:
var outputStr = output + '';
The powershell return should have come back in the output variable at which point you would be able to do something like this:
var outputList = new JSON().decode(output);
If the result is not appearing in the <output> tag you might try this instead:
$result = Invoke-RestMethod -Uri $uri -Method GET -Credential $cred | ConvertTo-Json
Write-Host $result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 11:55 AM
Tested with the output variable after using Write-Host to write the output. If I run it on a local machine shows going to stdout, but on SNOW I get no output in the history for that script. Also attempting to write it to the logs with gs.log nothing comes through. I get the log entry, but where the data should be is empty.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 12:04 PM
Yeah with the JSON you should see the byte-stream embedded in the returned ECC Queue input XML <output> tag. If it isn't there you aren't getting anything back from the command to return. So did you try my re-write of your last two lines?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 12:13 PM
Yeah tried the rewrite of the last two lines as well. The weird thing is that I get a return if I just paste the script in the command field in the Powershell activity. This only occurs when I am attempting to include a mid server script in the activity. Using the command now as a work around, but would prefer to have the saved mid server script so it can easily be reused.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 12:16 PM
Are you on Fuji yet? If so, you could build a custom activity definition really easily and even parse the JSON results as part of the activity to return just what you want.