Active IQ Unified Manager Discussions

Workflow for Netgroups


I'm pretty new to working with WFA 2.0. Has anyone looked into or thought about creating a workflow to add/modify the netgroups file?  I started looking into creating a command but there doesn't seem to be a cmdlet available to manipulate the /etc/netgroup file.  Any thoughts on how this might be accomplished?



So I'm working on my command in WFA.

It actually does what I want it to do. after the last line of code is done, this message show up in the test window.

21:58:23.941 ERROR  [Add New Entry to Existing NetGroup] Failed executing command. Exception: Cannot bind argument to parameter 'Data' because it is an empty string.

By removing certain parts of the command script, I have the part that seems to cause this error.  Anyone know why?

Get-Content $tempFile | where  {$_ -notmatch $ClusterName } | Write-NaFile -Path $File -AppendLine

Since the results of the where are getting written to  $File, I don't get it.


Yes, I've seen this before with the Write-NaFile cmdlet.  If memory serves, Write-NaFile didn't like lines that are blank or only contain whitespace.  You could try filtering them out as well, with something like:

Get-Content $tempFile | where  {$_ -notmatch $ClusterName -and $_ -notmatch "^\s*$" } | Write-NaFile -Path $File -AppendLine


that did it.  Thanks so much!


Could you provide your example command to add to an existing line in the netgroups file. I'm looking to do this as well but not sure how to get started. Thanks.


Branden Taber wrote:

Could you provide your example command to add to an existing line in the netgroups file. I'm looking to do this as well but not sure how to get started. Thanks.

Here is the command to write a new entry.  I'm no powershell expert, so I'm sure there may be an easier way to do this.

param (

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



  [parameter(Mandatory=$true, HelpMessage="New Cluster / Netgroup entry")]



  [parameter(Mandatory=$true, HelpMessage="New IP Address 1")]



  [parameter(Mandatory=$false, HelpMessage="New IP Address 2")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 3")]



  [parameter(Mandatory=$false, HelpMessage="New IP Address 4")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 5")]


  [parameter(Mandatory=$false, HelpMessage="New IP Address 6")]



  [parameter(Mandatory=$false, HelpMessage="New IP Address 7")]



  [parameter(Mandatory=$false, HelpMessage="New IP Address 8")]



  [parameter(Mandatory=$false, HelpMessage="New IP Address 9")]



  [parameter(Mandatory=$false, HelpMessage="New IP Address 10")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 11")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 12")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 13")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 14")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 15")]


   [parameter(Mandatory=$false, HelpMessage="New IP Address 16")]



# connect to controller

Connect-WFAController -Array $Array


$File = "/vol/vol0/etc/netgroup"


$backupFile = $File + ".wfabak"


# Back up the original file



          Read-NaFile $File | Write-NaFile $backupFile




          $msg = "Failed to back up: " + $File + " on: " + $Array + ". Message: " + $_.Exception.Message

          throw $msg



Get-WFALogger -Info -message $($File + " backed up successfully to: " + $backupFile + " on:  " + $Array)


# Add NetGroup Entry



               $allIPs = $NetGroupEntry01 + " " + $NetGroupEntry02 + " " + $NetGroupEntry03 + " " + $NetGroupEntry04 + " " + $NetGroupEntry05 + " " + $NetGroupEntry06 + " " + $NetGroupEntry07 + " " + $NetGroupEntry08 + " " + $NetGroupEntry09 + " " + $NetGroupEntry10 + " " + $NetGroupEntry11 + " " + $NetGroupEntry12 + " " + $NetGroupEntry13 + " " + $NetGroupEntry14 + " " + $NetGroupEntry15 + " " + $NetGroupEntry16

               foreach ($IP in $allIPs.split(" "))


                                        if ($IP -ne "")


                                                       $newclusterips = $newclusterips + "(" + $IP + ",,) "



      $newline = $ClusterName + " " + $newclusterips

      Write-NaFile -Path $File -AppendLine -Data $newline




               $msg = "Failed to form the netgroup line entry from: " + $File +  ". Message: " + $_.Exception.Message

               throw $msg



Get-WFALogger -Info -message $("New NetGroup Entry Created: " + $File + " on:  " + $Array)


# End of Command


Hi Patrick,

Please use the following cmdlet to add/modify entries to the desired files:


Write-NaFile -Path /vol/vol0/etc/netgroup -Data untrusted_hosts -AppendLine


Write-NcFile -Path <path> -Data <data>

Hope this helps in creating the command/workflow you need.



Thanks. That's helpful.  I assume an addition to already existing entry in the /etc/netgroup would be more involved?


If you're referring to making a change to an existing line, yes it would be more involved.  You should first make a backup of the existing file, then look into modifying it. 

Check out the example workflow I posted for manipulating /etc/hosts for some ideas, here:

Hope this helps,


NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.