Change DNS setttings

Welcome Forums General PowerShell Q&A Change DNS setttings

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 8 months ago.

  • Author
  • #71300

    Points: 0
    Rank: Member


    I have the following to change DNS settings on remote computers.
    I would like to be able to report back on all clients in the clients.txt file that failed to get their settings updated

    $dnsservers = "",""
    $computers = Get-Content "C:\clients\clients.txt"
    foreach ($comp in $computers) {
    $adapters = Get-WmiObject -q "select * from win32_networkadapterconfiguration where ipenabled='true'" -ComputerName $comp
    foreach ($adapter in $adapters)

  • #71323

    Points: 26
    Rank: Member

    Why you don't use Set-DnsClientServerAddress? With this you can use the parameter -ErrorAction Stop, and you could put the whole thing in a try/catch construct.

The topic ‘Change DNS setttings’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort