Active IQ Unified Manager Discussions

Error when executing Invoke-NaSSh



I am using brand new wfa2.1.

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.

What is wrong here?

Thanks for your help!




Hi Walter,

     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?



Hi Scott,

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.

Thanks for your help.



Hi Walter

     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 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

If ($DayOfMonth -eq "-1") {

     $DayOfMonth = "*"




Hi Scott,

no problem and thanks for your answer.

I tried the following:

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?

Best Regards




>>> As I am using WFA2.1: Could there be an error introduced with 2.1 regarding invoke-nassh in a workflow?

I tried a version of your command using code as follows through a workflow and seems to work fine for me. This was on WFA 2.1.

Command code I tried was:


Param (

        [parameter(Mandatory=$true, HelpMessage="Array name or IP address")]


        [parameter(Mandatory=$true, HelpMessage="Name of the volume for which the reallocate should be set up.")]


        [parameter(Mandatory=$false, HelpMessage="This threshold marks the defragmentation count for which reallocate should start. Default is 4")]


        [int]$Threshold = 4,

        [parameter(Mandatory=$false, HelpMessage="Reallocate Job Schedule: Minute (Valid values are from -1 to 59 with -1 meaning all possible values.)")]


        [int]$Minute = 8,

        [parameter(Mandatory=$false, HelpMessage="Reallocate Job Schedule: Hour (Valid values are from -1 to 23 with -1 meaning all possible values.)")]


        [int]$Hour = 2,

        [parameter(Mandatory=$false, HelpMessage="Reallocate Job Schedule: Day of month (Valid values are from -1 to 31 with -1 or 0 meaning all possible values.)")]


        [int]$DayOfMonth = -1,

        [parameter(Mandatory=$false, HelpMessage="Reallocate Job Schedule: Day of week (Valid values are from -1 to 6 with -1 meaning all possible values.)")]


        [int]$DayOfWeek = 6


#--- connect to controller

Connect-WfaController -Array $Array

#--- vars

$msg = $VolumeName + ": "

#---  Checks (and exits if checks fail)

$vol = Get-NaVol -Names $VolumeName -ErrorAction Stop

$volpath = "/vol/" + $                                          

$reallocstatus = Get-NaReallocate -ErrorAction Stop

if($reallocstatus -match "Reallocation [a-z ]* on$") {

   Get-WFALogger -Info -message $($msg + "Reallocation is already enabled on the storage system.")

} else {

   Get-WFALogger -Info -message $($msg + "Reallocation not yet enabled on the storage system -> enabling.")

   Enable-NaReallocate -ErrorAction Stop


if($Minute -lt 0) {

   $schedule = "*"

} else {

   $schedule = [string]$Minute


if($Hour -lt 0) {

   $schedule += " *"

} else {

   $schedule += " " + [string]$Hour


if($DayOfMonth -lt 1) {

   $schedule += " *"

} else {

   $schedule += " " + [string]$DayOfMonth


if($DayOfWeek -lt 0) {

   $schedule += " *"

} else {

   $schedule += " " + [string]$DayOfWeek


if($schedule -eq "* * * *"){

  throw $msg + "The schedule '" + $schedule + "' is not allowed."


#--- Configure the reallocate scan for the volume

$cmd = "reallocate start -t " + $Threshold + " -p " + $volpath

Invoke-NaSSH -Command  $cmd -ErrorAction Stop

# Invoke-WfaCli -CliCommand $cmd

Get-WFALogger -Info -message $($msg + "Scheduling the job: " + $schedule)

Set-NaReallocateSchedule -Path $volpath -Schedule $schedule -ErrorAction Stop


filer_prompt*> reallocate status -v

Reallocation scans are on


        State: Idle

        Flags: whole_vol,maybe_realloc,repeat,keep_vvbn

    Threshold: 4

     Schedule: 4 3 * 2

     Interval: n/a

Optimization: 1


If it still fails for you can you also paste the workflow details (command parameters sent) or the workflow DAR file.




Hi Shailaja,

thanks for trying this.

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.