Data Infrastructure Management Software Articles and Resources

Day-0 Command Example - Setting OnTap Options

This command takes Controller name or IP, OptionName, and OptionValue.  It sets OptionName to OptionValue on the Controller specified.  It uses try/catch so errors should be detected.  I'm also posting a sample workflow that uses this command.


To use this command, save the attached file and add a .dar extension. 

Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.


Just added this into my WFA commands, and looking good thus far, well it previews ok 

Cool.  Let me know how you like it. 

Yup I do like it, allows me to set the options that I need. Out of interest, how do you use the error trapping, so in this:


     Set-NaOption -OptionName


      $msg = "Failed to set OnTap option: " + $OptionName + " to value: " + $OptionValue + ". Message: " + $_.Exception.Message;

      throw $msg

Can you use this to error out the workflow to stop it? The reason I ask I need to be able to run a command on the console, so modified what you wrote to use the

Invoke-NaSsh -Command $Command

But if I put in a bogus command WFA still show this as successfull, so it doesnot look like the error trapping is working?

Cool.  Glad it's working for you.  It can be used for a lot of things, since so many things are controlled by options.

Absolutely, the 'try' will check all the commands in the code block for errors.  If one occurs, the 'catch' section will be executed.  The 'throw' function then causes the PowerShell command to exit with an error condition.  WFA will consider the Command failed and halt the workflow.

Now, the brilliance here is that someone monitoring WFA execution status can see that the workflow failed, go fix whatever caused it to fail, then 'resume' the workflow.  This retains all the user input variables, etc, and resumes the workflow by retrying the Command that failed.  If it succeeds, the workflow keeps on going like nothing ever happened.  To do this, right-click on the failed workflow from Execution Status and choose "Resume".

WFA resume.png

This works for failed workflows, not aborted/cancelled workflows.



Hmmm that's odd indeed. So in my code to run a command, this does not seem to work. For example if I get it to run the command "options autosupport.enable 123", which will give a error on the console, it does not return anything.... very odd.

Any thoughts on the below?

This is the code:

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

  [parameter(Mandatory=$true, HelpMessage="Command to run")]

# connect to controller
Connect-WFAController -Array $Array

Get-WFALogger -Info -message $("Excecuting command: " + $Command + " : on Filer ")

#Execute command

Invoke-NaSsh -Command $Command
$msg = "Failed to run the command: " + $Command + " to Array: " + $Array + $_.Exception.Message;
throw $msg

Yes, I think what's happening there is that the actual PowerShell command is "working", it does invoke SSH and it may execute the command, so 'try' may not be seeing an error. 

In my opinion, where there's a PowerShell Toolkit equivalent, it's better to use that than the SSH command.

Also, I have been seeing oddities with PowerShell when I put more than one parameter in the same variable.  I don't know if that has anything to do with your situation or not.

But, the way I've seen others code for Invoke-NaSsh failures is to put the output in a variable and parse that for a string that would indicate a failure, like:

$result = Invoke-NaSsh -Name $DFMServerName -Command $("dfpm dataset create " + $DatasetName)

if ($result.StartsWith("Error:"))
    throw $result

In this particular case, it would seem a) my command is better.   b) the failed options command has output that starts with the word "option" so if you want to make yours work, try using something like:

$result = Invoke-NaSsh -Command $Command

if ($result.StartsWith("option"))
    throw $result

Hope this helps,


Thanks Dave,

It's a pity that console commands (and perhaps the Invoke-NaSsh function) does not return a pass/fail flag I did think about parsing the results after capturing them into an array (have done this in other PowerShell scripts quite successfully) but I was hoping to make this more of a generic command. In fact what I am trying to do is set the lun reservation to disabled after creating the lun with Snap Drive, so trapping the word "option" won't really help me here.

Oh well guess I will just have to blindly run the command and hope for the best. Thanks for your help, and yes your version is better



It won't import into

Hmmm....  I haven't tried it on 2.2.  What errors are you getting?

Also, it's been a while.  I remember updating this command for 2.1.  It may not have been uploaded to this thread, but you can find the updated command and some comments about it in this other post:



All Community Forums