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}
}

}

21 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!

Leave a Reply

Your email address will not be published.