<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Scripting SVM Creation - Set-NcVserver -AllowedProtocols &amp;lt;input from hash table&amp;gt; in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Scripting-SVM-Creation-Set-NcVserver-AllowedProtocols-lt-input-from-hash-table/m-p/144538#M5882</link>
    <description>&lt;P&gt;Trying to setup a script using a hash table to create a new SVM. After the SVM is created I'm trying to set the allowed protocols with a comma seperated value from a hash table. It errors out with invalid value specifed. The only way I can get it to work is if I hard code the protocols in the script. Individually all other aspects of the command work as expected. Any help is grealy apprecidate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hash table values:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VserverName=usadbashb1tst&lt;/P&gt;
&lt;P&gt;Aggregates=data_*&lt;/P&gt;
&lt;P&gt;AllowedProtocol=nfs,iscsi &amp;lt;--I have also tried 'nfs','iscsi' with the same result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;D:\&amp;gt;Set-NcVserver -Name $values.VserverName -Aggregates $values.Aggregates -AllowedProtocols $values.AllowedProtocol&lt;/P&gt;
&lt;P&gt;Set-NcVserver : Invalid value specified for "allowed-protocols" element within "vserver-modify": "'nfs','iscsi'".&lt;BR /&gt;At line:1 char:1&lt;BR /&gt;+ Set-NcVserver -Name $values.VserverName -Aggregates $values.Aggregate ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt; + CategoryInfo : InvalidOperation: (usadbashb1000:NcController) [Set-NcVserver], EINVALIDINPUTERROR&lt;BR /&gt; + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Vserver.SetNcVserver&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 13:08:11 GMT</pubDate>
    <dc:creator>mcjunkin</dc:creator>
    <dc:date>2025-06-04T13:08:11Z</dc:date>
    <item>
      <title>Scripting SVM Creation - Set-NcVserver -AllowedProtocols &lt;input from hash table&gt;</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Scripting-SVM-Creation-Set-NcVserver-AllowedProtocols-lt-input-from-hash-table/m-p/144538#M5882</link>
      <description>&lt;P&gt;Trying to setup a script using a hash table to create a new SVM. After the SVM is created I'm trying to set the allowed protocols with a comma seperated value from a hash table. It errors out with invalid value specifed. The only way I can get it to work is if I hard code the protocols in the script. Individually all other aspects of the command work as expected. Any help is grealy apprecidate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hash table values:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VserverName=usadbashb1tst&lt;/P&gt;
&lt;P&gt;Aggregates=data_*&lt;/P&gt;
&lt;P&gt;AllowedProtocol=nfs,iscsi &amp;lt;--I have also tried 'nfs','iscsi' with the same result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;D:\&amp;gt;Set-NcVserver -Name $values.VserverName -Aggregates $values.Aggregates -AllowedProtocols $values.AllowedProtocol&lt;/P&gt;
&lt;P&gt;Set-NcVserver : Invalid value specified for "allowed-protocols" element within "vserver-modify": "'nfs','iscsi'".&lt;BR /&gt;At line:1 char:1&lt;BR /&gt;+ Set-NcVserver -Name $values.VserverName -Aggregates $values.Aggregate ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt; + CategoryInfo : InvalidOperation: (usadbashb1000:NcController) [Set-NcVserver], EINVALIDINPUTERROR&lt;BR /&gt; + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Vserver.SetNcVserver&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 13:08:11 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Scripting-SVM-Creation-Set-NcVserver-AllowedProtocols-lt-input-from-hash-table/m-p/144538#M5882</guid>
      <dc:creator>mcjunkin</dc:creator>
      <dc:date>2025-06-04T13:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting SVM Creation - Set-NcVserver -AllowedProtocols &lt;input from hash table&gt;</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Scripting-SVM-Creation-Set-NcVserver-AllowedProtocols-lt-input-from-hash-table/m-p/144540#M5883</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I think it's because the "-AllowProtocols" must be formatted as an array. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#'------------------------------------------------------------------------------
#'Function to format an array as a string.
#'------------------------------------------------------------------------------
Function Format-Array{
   Param(
      [Parameter(Mandatory=$False, HelpMessage="An array to format as a string expression")]
      [Array]$Array
   )
   [String]$result = "@("
   For($i = 0; $i -lt $Array.length; $i++){
      [String]$result += "'" + $Array[$i] + "'"
      If(($i + 1) -lt $Array.length){
         [String]$result += ","
      }
   }
   [String]$result += ")"
   Return $result
}
#'------------------------------------------------------------------------------
#'Set the allowed protocols.
#'------------------------------------------------------------------------------
[String]$VserverName = "vserver1"
[Array]$protocols    = @("cifs","nfs","iscsi")
[String]$command     = $("Set-NcVserver -Name $VserverName -AllowedProtocols " + $(Format-Array -Array $protocols) + " -ErrorAction Stop")
Try{
   Invoke-Expression -Command $command -ErrorAction Stop
   Write-Host "Executed Command`: $command"
}Catch{
   Write-Warning -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
   Break;
}
#'------------------------------------------------------------------------------
&lt;/PRE&gt;
&lt;P&gt;The output of the command is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Executed Command: Set-NcVserver -Name vserver1 -AllowedProtocols &lt;STRONG&gt;@('cifs','nfs','iscsi')&lt;/STRONG&gt; -Error
Action Stop&lt;/PRE&gt;
&lt;P&gt;Note: The "-AllowedProtocols" paramater is expressed as an array&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using a hashtable as your input for the allowed protcols you can assign the keys to an array and format it as expression. For Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#'------------------------------------------------------------------------------
#'Function to format an array as a string.
#'------------------------------------------------------------------------------
Function Format-Array{
   Param(
      [Parameter(Mandatory=$False, HelpMessage="A comma delimited string to format as an array")]
      [Array]$Array
   )
   [String]$result = "@("
   For($i = 0; $i -lt $Array.length; $i++){
      [String]$result += "'" + $Array[$i] + "'"
      If(($i + 1) -lt $Array.length){
         [String]$result += ","
      }
   }
   [String]$result += ")"
   Return $result
}
#'------------------------------------------------------------------------------
#'Set the protocols hashtable.
#'------------------------------------------------------------------------------
[Hashtable]$protocols = @{};
[Hashtable]$protocols.Add("cifs", 1)
[Hashtable]$protocols.Add("nfs", 1)
[Hashtable]$protocols.Add("iscsi", 1)
[Array]$allowedProtocols = $protocols.Keys
#'------------------------------------------------------------------------------
#'Set the allowed protocols.
#'------------------------------------------------------------------------------
[String]$VserverName = "vserver1"
[String]$command     = $("Set-NcVserver -Name $VserverName -AllowedProtocols " + $(Format-Array -Array $allowedProtocols) + " -ErrorAction Stop")
Try{
   #Invoke-Expression -Command $command -ErrorAction Stop
   Write-Host "Executed Command`: $command"
}Catch{
   Write-Warning -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
   Break;
}
#'------------------------------------------------------------------------------&lt;/PRE&gt;
&lt;P&gt;Hope that helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 22:56:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Scripting-SVM-Creation-Set-NcVserver-AllowedProtocols-lt-input-from-hash-table/m-p/144540#M5883</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2018-11-07T22:56:42Z</dc:date>
    </item>
  </channel>
</rss>

