how to debug result from a Run Powershell activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2015 10:38 AM
Hi,
I have been recently trying to use the orchestration workflow and use the Run Powershell activity to execute some commands via servicenow.
I have successfully executed the commands that i desired via mid server.
I have noticed that though my result is success via the script there is NO response in the XML payload from powershell and it becomes from servicenow side to sometimes debug what got failed even though the script was success.
Can anybody share their experience in debugging output from powershell.
1) Should i have some debugging statements in powershell code so that it will return back to servicenow activity ?
2) Should i have any specific debugging method for powershell activities in servicenow (apart from gs.log or workflow.debug).
Any guidance is highly appreciated.
Thanks,
Ishan
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2015 11:39 AM
Hi Ishan,
What version of the platform are you on? If you are on Fuji, I would recommend using Activity Designer. Run PowerShell is still supported but considered legacy. Activity Designer allows you to create well defined inputs/outputs. In Geneva you can test the activity without having to put the activity in a workflow.
Are you you seeing any errors in the Mid Script files?
What type of command are you running?
Is it a PowerShell remoting call?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2015 10:46 PM
We are new to Fuji, but Rebecca's comment is very interesting. I didn't realize Run PowerShell was considered legacy now.
In a lot of our Run PowerShell activities we have a very simple sensor script. Usually something like:
if(output != ''){
workflow.info("PowerShell Output: " + output);
}
if(error != ''){
workflow.scratchpad.errorMsg = error;
}
We would then create an error condition on the activity based on that errorMsg.
I think I need to look more into the Activity Designer now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2015 06:36 AM
Hi rebecca.dias,
Thanks for your reply !
We are on fuji and was not aware in detail about the activity designer. I shall investigate into that but currently i am using Run Powershell commands to execute my commands directly (not via powershell scripts but from the activity itself).
I am not receiving any errors when there is a success but on the contrary i am also not receiving any success response back it is always empty (even though the execution has happened correctly).
I have seen strange with powershell commands that if they are executed properly though the operation didn't happen (lets say the user to be added is already there) then it just gives a success back (which in technicality is not correct because the user was already available in the group so the script has done nothing), but i guess that is how powershell behaves. Strange !
Yes it is local service account on our mid server executing a remote call to AD server and executing the commands.
Basically i was looking for a good practice or a way to handle success and failure logs from powershell commands.
Thanks,
Ishan Parikh