none
Changing IP address on multiple machines from central windows server RRS feed

  • Question

  • So, i have a group of about 70 computers, they are currently situated on a closed network, every month or update cycle they need to be connected to the normal network for internet access, i recently found a script in thee forums written by a board member works really well, however i dot know if there is a way to modify this script to change all network cards IP address at one time to a different one then change them back again when completed, the network change would require all machines to receive static IP address. any one have any suggestions?

    $IPAddress=$(Read-Host "Specify your IP address (ie 192.168.1.10)")   
    $InterfaceIndex=$(Read-Host "Enter InterfaceIndex (ie 3) NOTE: Enter 'Show' for help")   
       
       
    foreach ($InterfaceIndex in $InterfaceIndex){   
       
            if ($InterfaceIndex -eq "Show" -eq "show") {   
                                                                     
                     Get-NetIPAddress | Format-List -Property InterfaceAlias,InterfaceIndex    
                                       
                    }   
                       
                    if ($InterfaceIndex -eq "Show" -eq "show") {   
                        $InterfaceIndex=$(Read-Host "Enter InterfaceIndex")   
                 }   
       
                    if (-Not ($InterfaceIndex -eq "Show" -eq "show"))    
                    {   
            }   
    }   
                           
       
       
    $SubnetMask=$(Read-Host "Enter the subnet mask in bits (ie 24 = 255.255.255.0)")   
    $DefaultGateway=$(Read-Host "Enter your Default Gateway (ie 192.168.1.1)")   
    $DNSAddresses=$(Read-Host "Set DNS Server Address/Addresses (ie 8.8.8.8)")   
       
    New-NetIPAddress -IPAddress $IPAddress -InterfaceIndex $InterfaceIndex -PrefixLength $SubnetMask -DefaultGateway $DefaultGateway   
    Set-DnsClientServerAddress -InterfaceIndex $InterfaceIndex -ServerAddresses $DNSAddresses   
       
    $Servers = $DefaultGateway,$DNSAddresses    
    $Ping=$(Read-Host "Do You want me to Ping your Default Gateway and DNS Servers? Yes/No")   
         
    if ($Ping -eq "Yes" -eq "yes") {   
       
        foreach ($Server in $Servers) {   
       
                   if (Test-Connection -ComputerName $Server -Count 2 -Quiet) {   
       
                        Write-Host "$Server is alive and Pinging " -ForegroundColor Green 
                           
                    }                      
                            else {   
                                     Write-Warning "$Server seems dead not Pinging"          
                                    }   
                 }   
        }   
                        if ($Ping -eq "No" -eq "no") {   
                                       
                                    Write-Host "Good bye!" 
                                     
                                            }   
                                       
                                    elseif (-Not ($Ping -eq "Yes" -eq "yes"))    
                 {  
                  
     }  
     
    Read-Host "Press any key to close..." 

    jeudi 7 novembre 2019 19:31

Toutes les réponses