Custom Powershell Activity Issue

tiyasa
Giga Expert

Hello,

I am trying to run a PowerShell script through a custom PowerShell activity in SN. When I test the inputs, I get the following output "Cannot bind argument to parameter 'String' because it is null.". No hresult and no errorMessages.

Can anyone suggest what this would mean and how can I resolve this?

find_real_file.png

Thanks,

~T

1 ACCEPTED SOLUTION

tiyasa


Everything looks fine in the log, in so much as PowerShell is running and reporting correctly. I think that one/all of your object attributes is not being set correctly. How are you reading inputs in your PS code? I see that you are passing variables to the function, such as $password and $title, but I don't see where you are importing them from your workflow. Maybe I'm missing something, but you would need to include something like this:



Your custom activity has inputs called "password" and title. To get those into PowerShell, you need:


$password = $env:SNC_password


$title = $env:SNC_title



You could also do:


addListItem -password $env:SNC_password -title $env:SNC_title



The inputs in the activity are treated like environment variables and SNC_<variable_name> is how they are referenced in PowerShell. Without this part, none of your object attributes would be populated and it would return the error you see.


View solution in original post

13 REPLIES 13

adilrathore
ServiceNow Employee
ServiceNow Employee

Have you tested the script out of ServiceNow. Does it work manually. It seems that some argument is missing within the script.


Hi,



Yes, manually the script works perfectly.


chadlockwood - Can you suggest? your blog on PowerShell custom activity was very helpful.


adilrathore
ServiceNow Employee
ServiceNow Employee

Do you have the contents of the script.