Friday, April 26, 2024
HomePowershellCreate a number of DNS A Information with PowerShell – SID-500.COM

Create a number of DNS A Information with PowerShell – SID-500.COM


PowerShell

Think about it’s important to create tons of or hundreds of DNS information. Do you wish to do this one after the other? Absolutely not. I’ll present you an instance how you can create Beamer01 – Beamer100 and assign an IP handle on the identical time. Let’s leap in.

The Goal

Let’s say we wish to create A Information Beamer01 – Beamer100 with the IP-Addresses 192.168.1.1 – 192.168.1.99.

The Code

Right here is the instance code you possibly can construct on. The script creates Beamer01 – Beamer99 with the corresponding IP addresses.

$ip = 1..99

foreach ($i in $ip) {

If ($i -lt 10) {

Add-DnsServerResourceRecord `
-ZoneName 'check.native' `
-Title Beamer0$i -IPv4Address 192.168.1.$i -A -Verbose

}
else 
{
Add-DnsServerResourceRecord `
-ZoneName 'check.native' `
-Title Beamer$i -IPv4Address 192.168.1.$i -A -Verbose
}
}

I hope this was useful.

Printed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2023], IT-Coach, IT-Advisor, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments