Remotely Setting HP ILO DNS Settings

Remotely Setting HP ILO DNS Settings

This script requires a module to be downloaded from the HP site for some of the commandlets to run.

[cc lang=”powershell”]

############################################################
#
# Set DNS Settings on Multiple HP ILOs
#
# NOK – Oct15
#  _    _ _____    _____ _      ____    _____  _   _  _____
# | |  | |  __ \  |_   _| |    / __ \  |  __ \| \ | |/ ____|
# | |__| | |__) |   | | | |   | |  | | | |  | |  \| | (___
# |  __  |  ___/    | | | |   | |  | | | |  | | . ` |\___ \
# | |  | | |       _| |_| |___| |__| | | |__| | |\  |____) |
# |_|  |_|_|      |_____|______\____/  |_____/|_| \_|_____/
#
############################################################

$password = ConvertTo-SecureString -String ‘ILOPASSWORD’ -AsPlainText -Force
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList (‘Administrator’, $password)
$ilos = Get-Content(‘c:\AllIlos.txt’)

# Get current DNS Settings for ILOs
$getDNS = @()
ForEach ($ilo in $ilos){
$GetDNS += Get-HPiLONetworkSetting -Server $ilo -Credential $creds | select HOSTNAME, PRIM_DNS_SERVER, SEC_DNS_SERVER
}

$getDNS > ‘C:\HPILODNS.txt’

# Set new DNS on ILOs

$getNewDNS = @()
ForEach ($ilo in $ilos){
Write-Host “Setting $ilo DNS…”
Set-HPiLONetworkSetting -server $ilo -PrimDNSServer ‘DNS SERVER 1 IP’ -SecDNSServer ‘DNS SERVER 2 IP’ -Credential $creds -EA SilentlyContinue
$GetNewDNS += Get-HPiLONetworkSetting -Server $ilo -Credential $creds | select HOSTNAME, PRIM_DNS_SERVER, SEC_DNS_SERVER, TER_DNS_SERVER
}

$getNewDNS > ‘C:\HPILOResults.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 *