none
Script to Chnage DNS configuration of Remote Windows servers RRS feed

  • Question

  • I am using this script to change the DNS settings on remote Windows servers:

    $computer = get-content C:\sl.txt
    $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
    Foreach($NIC in $NICs) {
       Write-Host "DNS Servers before  change:"
       $NIC.DNSServerSearchOrder

       $DNSServers = “198.102.234.125",”198.102.234.126"
       $NIC.SetDNSServerSearchOrder($DNSServers)
       $NIC.SetDynamicDNSRegistration(“TRUE”)
    }
    $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
    Write-Host "DNS Servers after change:"
    $NICs.DNSServerSearchOrder

    But, getting this as output:

    __GENUS : 2 __CLASS : __PARAMETERS __SUPERCLASS : __DYNASTY : __PARAMETERS __RELPATH : __PROPERTY_COUNT : 1 __DERIVATION : {} __SERVER : __NAMESPACE : __PATH : ReturnValue : 91

    I have also tried the script providing the Credentials, but still same error.

    Thursday, May 30, 2019 12:27 PM

All replies