PowershellGuru
  • Home
  • Active Directory Scripts
  • Script Repository
  • DHCP Scripts
  • DNS Scripts
  • Blogs
  • Community
  • Login
No Result
View All Result
PowershellGuru
  • Home
  • Active Directory Scripts
  • Script Repository
  • DHCP Scripts
  • DNS Scripts
  • Blogs
  • Community
  • Login
No Result
View All Result
PowershellGuru
No Result
View All Result
Home Powershell Script blogs

How to easily manage DNS Zone using PowerShell?

themeanmachine19@gmail.com by [email protected]
December 11, 2021
in Powershell Script blogs
0
How to easily manage DNS Zone using PowerShell?
Share on FacebookShare on Twitter

You might also like

Instant guide to convert ps2 to exe

Instant Guide To Convert PS1 To EXE (2022)

May 21, 2022
PowerShell tips and tricks

5 Useful PowerShell Tips and Tricks

May 15, 2022

Hello, PowerShell enthusiast today we will understand the interesting concept of DNS Zone and how to manage them using PowerShell. If you are already working in Windows server-related environment then you should be aware of the terms Primary, Secondary, and Stub zone in DNS. Let’s start our exciting journey for today and dwell on DNS.

How to easily manage DNS Zone using PowerShell?

What are Primary, Secondary, and Stub Zone in DNS?

Primary Zone:

As the name suggests it is a primary and important zone with a read-write portion of the DNS Namespace. Whenever a server has a DNS role has a primary zone hosted in that case the server then the server is an Authoritative server. In general, the DNS server created first in an environment will be an Authoritative DNS server.

Secondary Zone:

When it comes to Secondary Zone it can be termed as a copy-paste zone but only have read-only capabilities not write capabilities.

It is a friend of the Primary DNS zone who helps each other i.e. it shares the load on the Primary DNS zone with preventing a single point of failure.

Stub Zone:

Let me put it forward this way, there is a company X that hired a company Y, now they need to get merged but the domain Y.com won’t change but what you can do is you will be able to ping Y.com from X.com because of Stub zone. A stub zone is used to resolve the name between 2 different DNS namespaces.

Also, it contains a copy of the required resource records that is necessary to identify the authoritative DNS server.

 

Managing DNS Primary zone with PowerShell

#1 Creating Primary Zone

ZONE_NAME – Provide the Zone Name which needs to be created 

SCOPE – Replace scope with the following value: Forest, Domain, Legacy, or Custom

UPDATE_TYPE – Replace scope with the following value: None, Secure, or NonesecureAndSecure

				
					Add-DnsServerPrimaryZone -Name "Zone_Name" -ReplicationScope "Scope" -DynamicUpdate "update_type" –PassThru
				
			

#2 Removing Primary Zone

The below command is self-explanatory as it will remove the primary zone which is present in your domain.

				
					Remove-DnsServerZone -Name "Zone_Name" -ComputerName "DNS_server_Name"
				
			

Find more DNS related PowerShell scripts from here, DNS Scripts

Managing DNS Secondary zone with PowerShell

#1 Creating Secondary Zone

ZONE_NAME – Provide the name of the actual zone

ZONE_FILENAME – Replace with the same zone name, just append “.dns” at the end

MASTER_IP – Provide Master IP Address (Primary DNS server)

				
					Add-DnsServerSecondaryZone -Name "Zone_Name" -ZoneFile "Zone_FileName" -MasterServers "Master_IP"
				
			

#Removing Secondary Zone

				
					Remove-DnsServerZone -Name "Zone_Name" -ComputerName "DNS_server_Name"
				
			

Managing Stub Zone with Powershell

#1 Creating a Sub Zone

ZONE_NAME – Provide the name of the actual zone

MASTER_IP – Provide Master IP Address

SCOPE – values depending on the replication scope that you want to set: “Forest”, “Domain”, “Legacy”, or “Custom”

				
					Add-"DnsServerStubZone -Name ZONE_NAME" -MasterServers "MASTER_IP" -ReplicationScope "SCOPE"
				
			

#Removing Stub Zone

				
					Remove-DnsServerZone -Name "Zone_Name" -ComputerName "DNS_server_Name"
				
			

Conclusion

I hope you have liked the post How to easily manage DNS Zone using PowerShell? and will implement this whenever it is required. Things you should always remember is to try with one zone so that it will be easy for you to make changes. Let me know if you want a blog post on some other script that might amaze you.

We are working continuously to provide you with the better and the best scripts daily. We will publish weekly hence don’t forget to subscribe to our newsletter. 

Please login to join discussion
close

DON’T MISS A POST

Keep up to date with PowershellGuru

Powershell Blogs

PowershellGuru provides the best PowerShell scripts available that can be used and download freely. Do Check our blogs to get updated regularly.

Check your inbox or spam folder to confirm your subscription.

themeanmachine19@gmail.com

[email protected]

Related Stories

Instant guide to convert ps2 to exe

Instant Guide To Convert PS1 To EXE (2022)

by [email protected]
May 21, 2022
0

Instant guide to convert ps1 to exe. How to convert ps1 to exe. PS2exe. Convert ps1 to exe using ps2exe.

PowerShell tips and tricks

5 Useful PowerShell Tips and Tricks

by [email protected]
May 15, 2022
0

Useful Powershell tips and tricks. PowerShell tips and tricks. Know Powershell tips and tricks. get-help. get-alias.

tips to manage hyper-v using powershell

5 Tips To Manage Hyper-V Using PowerShell

by [email protected]
May 1, 2022
0

Tips to manage hyper-v using PowerShell. How to manage Hyper-V using PowerShell. Powershell to manage Hyper-V. Hyper-v and PowerShell.

Mistakes To Avoid While Writing A Powershell Script

5 Big Mistakes To Avoid While Writing A Powershell Script

by [email protected]
April 30, 2022
0

Mistakes to avoid while writing a powershell script. PowerShell mistakes. Avoid these mistakes in a powershell script. PowershellGuru.

Next Post
Mirroring two AD groups using PowerShell

Mirroring two AD groups using PowerShell (Fast)

Please login to join discussion

Recommended

error handling in powershell

Understanding Error handling in Powershell [2021]

August 20, 2021
How to find NTP Server using PowerShell?

How to find NTP Server using PowerShell?

November 27, 2021

About

Dhrub Bharali

PowerShell Enthusiast

Dhrub is hardcore Powershell enthusiast, he has wriiten more than 100 powershell scripts and he is the sole owner of PowerShellGuru.

Follow Us

Popular Story

  • Installing software remotely using powershell

    Easy way to install software remotely using PowerShell (2021)

    827 shares
    Share 331 Tweet 207
  • Detect Log4j vulnerable servers using PowerShell

    753 shares
    Share 301 Tweet 188
  • How to find NTP Server using PowerShell?

    738 shares
    Share 295 Tweet 185
  • Get-LocalGroupMember: Find Local admin using PowerShell (2021)

    728 shares
    Share 291 Tweet 182
  • Get installed software list quickly using PowerShell (2021)

    695 shares
    Share 278 Tweet 174
  • Home
  • Active Directory Scripts
  • Script Repository
  • DHCP Scripts
  • DNS Scripts
  • Blogs
  • Community
  • Login

© 2022 PowershellGuru- PowerShell Scripts For Automation

No Result
View All Result
  • Home
  • Active Directory Scripts
  • Script Repository
  • DHCP Scripts
  • DNS Scripts
  • Blogs
  • Community
  • Login

© 2022 PowershellGuru- PowerShell Scripts For Automation

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.