UPDATE DNS IP in List of computers

#Input file is CSV file with headers IPaddress

$Computers = import-csv “c:\temp\servers.csv”

ForEach ($Computer in $Computers) {
Write-Host “$($Computer.IPAddress): ” -ForegroundColor Yellow
Invoke-Command -ComputerName $Computer.IPAddress -ScriptBlock {

#input Cirrect DNS IP’S in the feals
$NewDnsServerSearchOrder = “10.10.1.200”,”10.10.1.106″
$Adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.DHCPEnabled -ne ‘True’ -and $_.DNSServerSearchOrder -ne $null}

    # Show DNS servers before update
    Write-Host "Before: " -ForegroundColor Green
    $Adapters | ForEach-Object {$_.DNSServerSearchOrder}

    # Update DNS servers
    $Adapters | ForEach-Object {$_.SetDNSServerSearchOrder($NewDnsServerSearchOrder)} | Out-Null

    # Show DNS servers after update
    $Adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.DHCPEnabled -ne 'True' -and $_.DNSServerSearchOrder -ne $null}
    Write-Host "After: " -ForegroundColor Green
    $Adapters | ForEach-Object {$_.DNSServerSearchOrder}
}

}

26 Comments

  1. What i don’t understood is in fact how you are not really a lot more neatly-appreciated than you may be now. You’re so intelligent. You realize therefore considerably in terms of this subject, made me personally believe it from numerous various angles. Its like women and men aren’t fascinated unless it is one thing to accomplish with Lady gaga! Your personal stuffs great. At all times take care of it up!

  2. I like what you guys are up also. Such clever work and reporting! Carry on the excellent works guys I¦ve incorporated you guys to my blogroll. I think it will improve the value of my website 🙂

  3. Hiya, I’m really glad I have found this information. Today bloggers publish just about gossips and internet and this is really irritating. A good website with interesting content, that’s what I need. Thanks for keeping this web site, I’ll be visiting it. Do you do newsletters? Can not find it.

  4. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four e-mails with the same comment. Is there any way you can remove people from that service? Cheers!

  5. I do not even know how I ended up here, but I thought this post was good. I don’t know who you are but certainly you are going to a famous blogger if you aren’t already 😉 Cheers!

  6. I do like the manner in which you have framed this situation and it does indeed present me personally some fodder for consideration. On the other hand, because of what precisely I have personally seen, I basically hope as the actual opinions pile on that people today continue to be on point and don’t get started on a soap box regarding some other news du jour. Yet, thank you for this exceptional point and although I can not necessarily go along with this in totality, I regard the point of view.

Leave a Reply

Your email address will not be published.