none
Check new DNS servers from remote client and update DNS IPs RRS feed

  • Question

  • Hi Guys, 

    I would like to change DNS servers IPs on some remote computers, but i'have first to check that this new DNS servers are rechable by thoses clients, the goal is to check that the new DNS Ips are recheable and port 53 is listening.

    Afterthat, if successful, it will update the DNS records by the new ones.

    I tried to build a script for doing the job, but i'am still confused by that, if someone can give some help i will appreciate.

    Thanks a lot in advance to you powershell gurus :) 

    Regards

    $computers = get-content C:\Temp\input.txt
    
    Foreach ( $computer in $computers) {
        IF (Test-Connection -Count 1 -ComputerName $computer -Quiet) {
            Write-Host "The remote machine is Online"
        
        $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer | where{$_.IPEnabled -eq “TRUE”}
        $ipaddress = @{192.168.20.88 192.168.30.89}
        $port = 53
        $connection = New-Object System.Net.Sockets.TcpClient($ipaddress, $port)
             if ($connection.Connected) {
               Write-Host "Success"
            
                 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”)
                 }
             else {
             Write-Host "DNS port check is Failed"
             }
             
    
    $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
    Write-Host "DNS Servers after change:"
    $NICs.DNSServerSearchOrder
            
            }
       
        }
    
     Else {
            Write-Host "The remote machine is Down"
    }
    
    


    vendredi 6 avril 2018 18:54

Toutes les réponses

  • Bonjour,

    pouvez-vous utiliser le français sur ce forum? Or could you please use the English forums for this question?

    Thanks.

    Avez-vous une solution pour tester à partir de la station que l'on veut configurer que celle-ci atteint bien les serveurs DNS que l'on veut configurer ?

    Autant, il est facile de tester la connexion à partir du poste d'administration lançant le PowerShell, autant je ne suis pas sur du tout que votre méthode soit utilisable comme cela.

    A bientôt


    Thierry DEMAN. Exchange MVP. MCSE:Messaging 2013,MCSE:Server Infrastructure 2012(83 MCPs). MCSA Office 365 https://mvp.microsoft.com/en-us/mvp/Thierry%20Deman-7660 http://base.faqexchange.info

    samedi 7 avril 2018 09:02