I wrote a custom command setting reallocate schedules for volumes. Unfortunately cmdlet start-nareallocate does not set the threshold to the value provided to the cmdlet. It always sets 1. Because of this I want to use invoke-nassh with the following command "reallocate start -t 4 -p /vol/volname".
When this custom command is executed out of a workflow it runs without errors. Executing this custom command in a workflow throws the following error:
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
When I remove the invoke-nassh cmdlet then the command finishes without errors. When I replace the "reallocate ..." with "abc" the same error is thrown (whereas I would except some exception from the controller because debug is no known command). When I relocate the invoke-nassh cmdlet to the beginning of the command then this error is thrown immediately after starting the command. When I relocate the invoke-nassh cmdlet to the end of the command then every step is executed until the cmdlet is reached and again this error is raised.
Did you copy the command into part of an existing workflow? It sounds like a param somewhere in the code itself may be set to an array. Can you "sanitize" anything sensitive to you and post the command?
yes, I inserted the command in an already existing workflow.
Attached you can find the command. The version in the attachment is running without an error (besides that it cannot set the threshold because the powershell cmdlet is erroneous). When I comment out the line starting with "Start-NaReallocate" and remove the comment from the lines starting with "$cmd ..." and "Invoke-NaSSH ..." the error described is thrown.
If testing the command without a workflow then it is working in both versions. But embedded in the workflow it fails when using Invoke-NaSSH.
Sorry for the delay, something changed on my DNS and WFA was not logging into the controllers properly.
To level set, I am running WFA 2.0.1 and the 18.104.22.168 version of the ONTAP toolkit.
I was not able to reproduce the error, all three volumes that I tried to reallocate worked without issue. However when you are building your values in your parameters, you will be trying to pass -1 to the frame for $DayOfMonth as you are using invoke-nassh. When using the invoke command you would need to substitute "*"(splat, asterisk, star) in the command if my thinking is correct.
I would wrap an if(something like this) around that command such as the one below would fix your error
I removed all statements from the command except the parameter definition at the beginning, the connect-wfacontroller and a 'invoke-nassh "abc" -erroraction stop'. When executing this little command in my workflow it still throws the error ("Index was out of range ...")
Then I tried the following:
I took the little command and substituted the 'invoke-nassh" with 'get-wfalogger -info -message $("debug")'. Now executing this and the workflow finished without errors.
As I mentioned, the original command which I posted is running outside of the workflow (when running with the "test" button in the command edit window) without errors.
As I am using WFA2.1: Could there be an error introduced with 2.1 regarding invoke-nassh in a workflow?
I cannot explain this behaviour. As I described, I took the same workflow with the same configuration in two ways:
a) deleting every statement from the command except the parameter config and the invoke-nassh command -> failure
b) then changing invoke-nassh to get-wfalogger in the same workflow and with the same parameters (template) -> success
For me, this cannot be a problem with the parameters sent to the command or with the workflow because this is in both tests the very same. It, too, cannot be a problem of the command because it is running without failure when testing in the command editing window.