Archivi tag: cname

Powershell: importare record DNS da file CSV

Script per importare record A e Cname nel DNS da un file CSV

Esempio di file CSV:
HostName,RecordType,IPAddress
server01,a,192.168.1.1
Service01,cname,server4.mydomain.com

Script

<# CSV example
HostName,RecordType,IPAddress
server01,a,192.168.1.1
Service01,cname,server4.mydomain.com
#>

$CSV = Read-Host "CSV to import:"
$Zone = Read-Host "Zone Name:"
Import-CSV $CSV |
%{
if ($_.RecordType -eq "a") {Add-DnsServerResourceRecordA -Name $_.HostName -ZoneName $zone -IPv4Address $_.IPAddress} 
elseif ($_.RecordType -eq "cname")  {Add-DnsServerResourceRecordCName -Name $_.HostName -ZoneName $zone -HostNameAlias $_.IPAddress}
}