Last active
October 12, 2018 09:27
-
-
Save codyde/393d48244a0a7eb6676b482edd4c6b35 to your computer and use it in GitHub Desktop.
DNS Update Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory = $True)] | |
[String]$Hostname, | |
[Parameter(Mandatory = $True)] | |
[String]$Domain, | |
[Parameter(Mandatory = $True)] | |
[String]$IP | |
) | |
Function Get-SafeString($value) { | |
if ($value -eq $null) { | |
Write-Output '' | |
} else { | |
Write-Output $value.ToString() | |
} | |
} | |
Function Invoke-DNSRecord($Hostname, $Domain, $IP) { | |
write-host "Hostname is $Hostname" | |
write-host "Domain is $Domain" | |
write-host "IP Address is $IP" | |
$props = @{ | |
'Hostname' = Get-SafeString $Hostname | |
'Domain' = Get-SafeString $Domain | |
'IP' = Get-SafeString $IP | |
} | |
$Object = New-Object PSObject -Property $props | |
Write-Host "$Object" | |
Add-DnsServerResourceRecordA -name $Object.Hostname -ZoneName $Object.Domain -AllowUpdateAny -IPv4Address $Object.IP -TimeToLive 300 | |
} | |
Invoke-DNSRecord -Hostname $Hostname -Domain $Domain -IP $IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment