PowerShell for DNS Part 4
In this lecture I’m going to show you how to create multiple A-Host records. With these commands you can create 5 or a hundred A-host records in seconds with PowerShell.
- In case you forgot an A record associates a domain name to the matching IP address of that computer.
We will be working from the Domain Controller IPDC01.
- I encourage you to follow along as all this information has been included in the lesson that came with the lecture.
So, the first thing that were going to do is were going to click on windows explorer and I want to show you folder that I created, called scripts.
So, within that folder I created a CSV file called computers.csv.
- So, what’s a CSV file? It’s’ a comma separated value file)
Now within this file, I have two column headers, one is Hostname separated by a coma, and the other is IPAddress. Underneath my Hostname are all my hosts, IPSW05 through IPSW14. And all the associated IP addresses.
- These hostnames are for testing purposes if you were creating these for a production network you would need to change the IPAddress to correspond to your IP network and change the hostnames to whatever will work best in your environment.
HostName,IPAddress
IPSW05,10.0.2.30
IPSW06,10.0.2.31
IPSW07,10.0.2.32
IPSW08,10.0.2.33
IPSW09,10.0.2.34
IPSW10,10.0.2.35
IPSW11,10.0.2.36
IPSW12,10.0.2.37
IPSW13,10.0.2.38
IPSW14,10.0.2.39
- Now how do you create a CSV file? You click file, save as. Click save as type, then click All Files. For a filename type computers.csv. Normally you would click save, but I will click cancel.
Now let’s go ahead and open up PowerShell in Administrative mode.
Here’s our script
-
Import-CSV -Path C:\Scripts\computers.csv | %{ Add-DNSServerResourceRecordA ZoneName instructorpaul.com -Name $."Hostname" -IPv4Address $."IPAddress" }
-
What we have here is two commands. Command #1 is Import-CSV and Command #2 is…
No comments yet. Add the first comment to start the discussion.