Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, November 28, 2018 10:39 AM
Given the number of DNS powershell commands available, I feel like I'm missing something here!
How can I create a domain called testing in the contoso.com domain with Powershell?
DNS GUI: Right click contoso.com, click New Domain and we're done.
All replies (5)
Wednesday, November 28, 2018 10:43 AM
Hello!
Maybe this could be of any help?
Create AD Child Domain with PowerShell
https://blogs.technet.microsoft.com/poshchap/2015/03/13/create-ad-child-domain-with-powershell/
How To Deploy An Active Directory Sub Domain In Unattended Mode Using PowerShell
https://www.ntweekly.com/2016/07/20/how-to-deploy-an-active-directory-sub-domain-in-unattended-mode-using-powershell/
Best regards,
Leon
Blog: https://thesystemcenterblog.com LinkedIn:
Wednesday, November 28, 2018 11:39 AM
Thanks, but that's all for Active Directory Domains, not DNS domains.
Wednesday, November 28, 2018 12:12 PM
Ah apologies, thought it was Active Directory Domain.
I'm not sure if you can with PowerShell, but it is possible with dnscmd.
Syntax
dnscmd [<ServerName>] /recordadd <ZoneName> <NodeName> <RRtype> <Rrdata>
This adds a record to a specified zone in a DNS server.
Parameters
<ServerName> Specifies the DNS server to manage, represented by local computer syntax, IP address, FQDN, or host name. If this parameter is omitted, the local server is used.
<ZoneName> Specifies the zone in which the record resides.
<NodeName> Specifies a specific node in the zone.
<RRtype> Specifies the type of record to be added.
<Rrdata> Specifies the type of data that is expected.
Note: When you add a record, make sure that you use the correct data type and data format. For a list of resource record types and the appropriate data types, see Resource records reference.
Example
dnscmd /RecordAdd mydomain.com subdomain.com A 192.168.1.20
Blog: https://thesystemcenterblog.com LinkedIn:
Wednesday, November 28, 2018 12:29 PM
Thanks.
I've just discovered that the "New Domain" option in the GUI is a bit of smoke and mirrors https://social.technet.microsoft.com/Forums/windows/en-US/5624ffbf-96dd-4d62-91f6-8bdcc264ef71/create-a-new-dns-domain-within-a-zone-using-script?forum=winserverDS
"If you only create an empty domain (subdomain in your zone) with the GUI; the file is not updated! When you stop & start the DNS server, you'll even see that the empty domain is gone.
So that means that using 'New Domain..." from the GUI really doesn't do anything in your zone, until you add a record."
So creating an A record with the required domain name should work.
Wednesday, October 30, 2019 1:56 PM
Came across this as I had the same issue but found that creating a resource record with the domain name included in the name will create the domain.
EG:
Add-DnsServerResourceRecore -ZoneName "Company.com" -A -Name "Test.DepartmentA" -IPv$Address "192.168.1.1"
This will create the subdomain "DepartmentA" in the zone "Company.com" with an A record of "Test" pointing to "192.168.1.1"
Not sure if you still need to know but thought adding my finding would help someone.