Effective December 3, NetApp adopts Microsoft’s Business-to-Customer (B2C) identity management to simplify and provide secure access to NetApp resources.
For accounts that did not pre-register (prior to Dec 3), access to your NetApp data may take up to 1 hour as your legacy NSS ID is synchronized to the new B2C identity.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Software Development Kit (SDK) and API Discussions

PSTK: Remove-NcNetDns missing




I notice that there is Get-NcNetDns and Set-NcNetDns (to get the list of DNS servers, and to change the DNS servers), but there is no corresponding Remove-NcNetDns to remove the DNS config from an SVM or the Cluster.


Would it be possible to add that commandlet to the next version of PSTK? Currently we're relying on Invoke-NcSSH for that, and that has some other quirks that make it undesirable






The"" will not in Ontap 9. It use to work in Data Ontap 8.

::*> dns modify -vserver vs1 -domains domain.local -name-servers "" 
Error: command failed: Invalid value specified with "-name-servers". Specify a
       valid IP address.



You can actually use the "Set-NcNetDns" command to remove DNS servers from the configuration by just using empty double quotes for the NameServers parameter. (code snippet from the output of the "Get-Help Set-NcNetDns -Examples command"): 


    --------------  Example 3 --------------

    C:\PS>Set-NcNetDns -NameServers ""

    Remove the name server list from the DNS configuration of the current vserver.



Did you actually try that command? Because it was the first thing I tried, and it doesn't work:


PS C:\> set-ncnetdns -vserver ClusterF -NameServers ""
set-ncnetdns : Invalid value specified with "-name-servers". Specify a valid IP address.
At line:1 char:1
+ set-ncnetdns -vserver ClusterF -NameServers ""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ( [Set-NcNetDns], EAPIERROR
    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Net.SetNcNetDns



Dang, that's what I get for assuming that a cmdlet will work according to its documentation! 🙂 


It looks like there's a discrepancy between what the cmdlet itself accepts for the NameServers parameter and what the "name-servers" parameter in ZAPI accepts.  From the de-compiled Set-NcNetDns cmdlet:


[Parameter(HelpMessage = "Addresses of name servers such as ''.", Position = 1, ValueFromPipelineByPropertyName = true)]
    [Alias(new string[] {"Servers"})]
    public string[] NameServers { get; set; }

 And the ZAPI:

<?xml version="1.0" encoding="UTF-8"?>
<netapp  xmlns="http://www.netapp.com/filer/admin" version="1.160">


PS C:\users\donny.lang\desktop> $Request = @"
>>   <net-dns-modify>
>>     <name-servers>
>>       <ip-address>""</ip-address>
>>     </name-servers>
>>   </net-dns-modify>
>> "
PS C:\users\donny.lang\desktop> Invoke-NcSystemApi -Request $Request -VserverContext lab-svm-01
Invoke-NcSystemApi : Invalid value specified for "name-servers" element within "net-dns-modify": """".
At line:1 char:1
+ Invoke-NcSystemApi -Request $Request -VserverContext lab-svm-01
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ( [Invoke-NcSystemApi], EINVALIDINPUTERROR
    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.System.InvokeNcSystemApi

 I wonder if it worked in an older version of the API and was removed/changed for some reason. 

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.

NetApp Insights to Action
I2A Banner