Remotely setting Kemp NLB DNS Settings

Remotely setting Kemp NLB DNS Settings

This script requires the Kemp PowerShell modules to be downloaded from Kemps support site.
At the time of writing these were still in a beta stage.

[cc lang=”Powershell”]

##################################################
#
#  PowerShell Script to Get and change the DNS
#  Kemp NLB to facilitate new DNS servers
#                                           NO’K
#  _  ________ __  __ _____    _____  _   _  _____
# | |/ /  ____|  \/  |  __ \  |  __ \| \ | |/ ____|
# | ‘ /| |__  | \  / | |__) | | |  | |  \| | (___
# |  < |  __| | |\/| |  ___/  | |  | | . ` |\___ \
# | . \| |____| |  | | |      | |__| | |\  |____) |
# |_|\_\______|_|  |_|_|      |_____/|_| \_|_____/
#
##################################################

$ModuleLoc = “C:\Kemp.LoadBalancer.Powershell.psm1”
$LoadMasters = (Get-Content ‘C:\nlbs.txt’)

$onlinelist = @()
$offlinelist = @()
$oldDNS = @()
$newDNS = ‘1.1.1.1,2.2.2.2’

$creds = Get-Credential

Import-Module $ModuleLoc

$LoadMasters|%{if(Test-Connection $_ -Quiet -Count 2){
Write-Verbose “`t $_ is up”; $onlinelist += $_}
else{Write-Warning “`t`t`t`t $_ is not contactable”; $offlinelist += $_}
}
if($offlinelist -ne $null){
$ofs=”,”; $offl #   Write-Verbose “Checking Connection to $kemp”
$OfflineMsg=”The following Kemps are offline: $offlinelist”;$ofs=” “}
$onlinelist|%{
#Write-Host “Initilizing Connection to $kemp” -backgroundcolor yellow
Initialize-LoadBalancer -Address $_ -LBPort 443 -Credential $creds}

$outfileA = $onlinelist|%{Get-DNSConfiguration -LoadBalancer $_ | Select ‘HA1Hostname’, ‘HA2Hostname’, ‘NamServer’}
$outfileA | Out-File ‘C:\KempDNS.txt’

$outfileB = $onlinelist|%{Set-DNSConfiguration -LoadBalancer $_ -NameServer $newDNS }
$outfileB | Select ‘HA1Hostname’, ‘HA2Hostname’, ‘NamServer’| Out-File ‘C:\KempnewDNS.txt’

[/cc]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *