- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 03:17 PM
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?
Thanks,
~T
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2017 08:09 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 02:48 AM
I found the logs in the mid server folder as below, but I don't see anything except the error.
Maybe your experienced eyes can catch something more?
10/17/17 11:45:36 (483) LogStatusMonitor.60 stats threads: 64, memory max: 910.0mb, allocated: 282.0mb, used: 29.0mb, standard.queued: 0 probes, standard.processing: 0 probes expedited.queued: 0 probes, expedited.processing: 0 probes interactive.queued: 0 probes, interactive.processing: 0 probes
10/17/17 11:45:39 (030) Worker-Standard:PowershellProbe Worker starting: Powershell source: WK01LT586.eu.wkeurope.com
10/17/17 11:45:41 (534) Worker-Standard:PowershellProbe Public SNMP Credentials loaded
10/17/17 11:45:41 (534) Worker-Standard:PowershellProbe WARNING *** WARNING *** No credentials from instance were loaded. MID server may not have access to credentials table
10/17/17 11:45:41 (534) Worker-Standard:PowershellProbe DEBUG: Windows credentials all failed... Attempting to use the credential from the local MID server.
10/17/17 11:45:41 (538) Worker-Standard:PowershellProbe DEBUG: Attempting script with credential from the local MID server service credential
10/17/17 11:45:41 (540) Worker-Standard:PowershellProbe DEBUG: Running command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy unrestricted -noninteractive -nologo -noprofile -command "& {& 'scripts\PowerShell\PSScript.ps1' -computer 'WK01LT586.eu.wkeurope.com' -script 'C:\windows\TEMP\AddListItems_SiteDirectory.ps17656252358674634518.PS1' -useCred $false -isDiscovery $false -debug $true; exit $LASTEXITCODE}"
10/17/17 11:45:41 (548) Worker-Standard:PowershellProbe DEBUG: Thread name is Powershell is executing...
10/17/17 11:45:42 (168) Gobbling stdout: Powershell is executing... Gobbled: <powershell>
10/17/17 11:45:42 (168) Gobbling stdout: Powershell is executing... Gobbled: <output>
10/17/17 11:45:42 (336) Gobbling stdout: Powershell is executing... Gobbled: System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'String' because it is null.
10/17/17 11:45:42 (336) Gobbling stdout: Powershell is executing... Gobbled: at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
10/17/17 11:45:42 (336) Gobbling stdout: Powershell is executing... Gobbled: at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
10/17/17 11:45:42 (337) Gobbling stdout: Powershell is executing... Gobbled: at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
10/17/17 11:45:42 (337) Gobbling stdout: Powershell is executing... Gobbled: at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
10/17/17 11:45:42 (337) Gobbling stdout: Powershell is executing... Gobbled: </output>
10/17/17 11:45:42 (337) Gobbling stdout: Powershell is executing... Gobbled: </powershell>
10/17/17 11:45:42 (343) Worker-Standard:PowershellProbe DEBUG: The exit value from waitFor() is 0
10/17/17 11:45:44 (386) Worker-Standard:PowershellProbe DEBUG: The status code returned from running the command is 0
10/17/17 11:45:44 (386) Worker-Standard:PowershellProbe DEBUG: Queuing Powershell Windows - Powershell (nodes: 3)
10/17/17 11:45:44 (386) Worker-Standard:PowershellProbe Sending to queue: Powershell,Windows - Powershell (nodes: 3),WK01LT586.eu.wkeurope.com
10/17/17 11:45:44 (386) Worker-Standard:PowershellProbe Document: <?xml version="1.0" encoding="UTF-8"?><results probe_time="5356" result_code="0"><result>
<output>
System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'String' because it is null.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
</output>
</result><parameters><parameter name="MIDScriptFile" value="scripts\PowerShell\AddListItems_SiteDirectory.ps1"/><parameter name="agent" value="mid.server.Test Server"/><parameter name="used_by_runbook" value="true"/><parameter name="glide.xmlhelper.trim.enable" value="true"/><parameter name="source" value="WK01LT586.eu.wkeurope.com"/><parameter name="skip_sensor" value="true"/><parameter name="sys_id" value="5d46b2ee4f350300bf3b06f18110c74b"/><parameter name="sys_created_on" value="2017-10-17 09:44:54"/><parameter name="state" value="ready"/><parameter name="probe_name" value="Windows - Powershell"/><parameter name="debug" value="true"/><parameter name="workflow" value="test_button_workflow_sys_id"/><parameter name="execution_sys_id" value="d946b2ee4f350300bf3b06f18110c74b"/><parameter name="priority" value="2"/><parameter name="agent_correlator" value="ProviderRunner.1546b2ee4f350300bf3b06f18110c74b"/><parameter name="probe" value="ca9edfec0a0a0baa011fe82922346887"/><parameter name="sequence" value="15f29b8bdf80000001"/><parameter name="name" value="Windows - Powershell (nodes: 3)"/><parameter name="topic" value="Powershell"/><parameter name="queue" value="output"/><parameter name="ecc_queue" value="5d46b2ee4f350300bf3b06f18110c74b"/></parameters></results>
10/17/17 11:45:44 (391) Worker-Standard:PowershellProbe Enqueuing: C:\MID SERVER\SN-Test-Server\agent\work\monitors\ECCSender\output_2\ecc_queue.5d46b2ee4f350300bf3b06f18110c74b.xml
10/17/17 11:45:44 (396) Worker-Standard:PowershellProbe Worker completed: Powershell source: WK01LT586.eu.wkeurope.com time: 0:00:05.356
10/17/17 11:45:44 (722) ECCSender.1 Sending ecc_queue.5d46b2ee4f350300bf3b06f18110c74b.xml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2017 06:17 AM
Any chance you got to review Chad?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2017 08:09 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2017 08:09 AM
Spot On. Indeed my inputs were not getting passed to the script, when I hardcoded in the script in SN, it worked.
I also tried your suggestion of using $env:SNC_ and it worked perfectly.
Appreciate all the help. Thank you a bunch!