Skip to main content

Deploying AD Domain using PowerShell + Completing LAB Setup

I would like to divide this post in two parts :
1. Deploying a domain dexter.com on my Server Core .
2. Adding my Physical Host running Server 2012 to the domain dexter.com.


Step 1. Deploying domain dexter.com on my Server Core.

First of all I need to add the Active Directory Domain Services role in my Server Core. To get the Active Directory Roles on my Server Core use the following cmdlet


The highlighted entry shows that the AD-Domain-Services Role is already installed on my Server Core. But if it is not then you can issue the following to install it.

Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools

Now the role is installed and till Server 2K8 R2 , one would have gone and run the dcpromo.exe (this one is deprecated now with Server 2012) but here I will try to use PowerShell ..this is the link I followed


Windows Server 2012 has a new module named " ADDSDeployment" and if I check the cmdlets supplied:

 
You get the idea...Now I am going to setup a Forest with the domain "dexter.com" this one is all in my internal Hyper-V network...Remember I added a internal virtual switch using the Add-VMSwitch cmdlet in this Post.

Now my best clue is Install-ADDSForest will do the job, so let's kick the help first :


But wait there is one cool cmdlet Test-ADDSForestInstallation which runs the prerequisites (only) for installing a new forest in Active Directory . You can try this but anyways when you .

##########################################################################
But Wait what's the Secret to all this learning...I sure didn't came up with all this..What I did is as under.

Now what I really did was fire-up server manager on my Server 2012 with GUI (base machine) ..
Click on "Promote this Server to a Domain Controller"



Next a wizard similar to dcpromo.exe shows up



Now in next few pages set the password, domain and forest functional level etc and then finally there will come a screen like the following ....



Now click on the "View Script" to get the equivalent PowerShell script that will do the same changes as you selected in the Wizard...Now use this script (after appropriate changes..ofcourse ) to deploy the Forest on your Server Core....Cool way to learn , eh !

Following is the Script I executed in my Server Core to install the domain dexter.com...I haven't done any changes like changing the Domain and Forest Functional Level but this may change according to your needs.
Import-Module ADDSDeployment
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath "C:\Windows\NTDS" `
-DomainMode "Win2012"  -DomainName "dexter.com"  -DomainNetbiosName "DEXTER" `
-ForestMode "Win2012" -InstallDns:$true -LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false -SysvolPath "C:\Windows\SYSVOL" -Force:$true




Step 2. Adding my Physical Host running Server 2012 to the domain dexter.com.

Now, I have a domain "dexter.com" running in my Hyper-V internal network. But the problem is I am connected to a public network on my Physical Host with Server 2012...and through which I access internet.

So here is what I did to add my physical machine (DexterPOSH) to the domain dexter.com and still access the Internet

First let's check the Net Adapter's on my DexterPOSH machine ...


I have renamed the Adapter as "Internet" to indicate that I access Internet through it using Rename-NetAdapter cmdlet. Now assign the IP "192.168.1.1" and DNS "192.168.1.2" to the Hyper-V Internal Adapter with ifindex "18"....wondering how ? see my previous post ...to do it via Shell. 

Now get the Net IP Configuration
 
  Now, If you try Test-Connection 192.168.1.2 (dexservercore) it shows it's online....But when you do this
Test-Connection dexservercore and Test-connection dexter.com....what it does is it looks out through your internet connected address and resolve the IP address.

What I want is that whenever my Machine tries to reslove "dexter.com" it should not go to the Internet rather my inernal network having dexter.com domain on machine dexservercore. There may be a various ways to do this but the simplest solution I tried was to edit the hosts file at location C:\Windows\System32\Drivers\etc\hosts and add the following entry to it.

192.168.1.2    dexter.com
192.168.1.2    dexterservercore


So now whenever I try to contact dexter.com or dexservercore it just resolves the IP address from here (Oh! Wait it means the dexter.com on the Internet can't be resolved by my system now..Guess will have to live with that.. :) :D lol ).

 Now a better way can be to add DNS Server Role to my phsical machine add an entry for it. But this one is simple and effective and works fine too... :)

Last, step now is to add my machine to the domain. Issue the following on the Shell :

   
So the end result is I have a domain dexter.com on my server core (dexservercore) and my physical host (dexterposh) is connected to the domain dexter.com and internet is running fine too....so to just prove it get the connection profile...



 
That's all for now...

Popular posts from this blog

Test connectivity via a specific network interface

Recently while working on a Private cloud implementation, I came across a scenario where I needed to test connectivity of a node to the AD/DNS via multiple network adapters.  Many of us would know that having multiple network routes is usually done to take care of redundancy. So that if a network adapter goes down, one can use the other network interface to reach out to the node. In order to make it easy for everyone to follow along, below is an analogy for the above scenario: My laptop has multiple network adapters (say Wi-Fi and Ethernet) connected to the same network. Now how do I test connectivity to a Server on the network only over say Wi-Fi network adapter?

PowerShell + SCCM : Run CM cmdlets remotely

Today I saw a tweet about using implicit remoting to load the Configuration Manager on my machine by Justin Mathews . It caught my eye as I have never really tried it, but theoretically it can be done. Note - The second tweet says "Cannot find a provider with the name CMSite", resolution to which is in the Troubleshooting section at the end.

PowerShell : Trust network share to load modules & ps1

Problem Do you have a central network share, where you store all the scripts or PowerShell modules ? What happens if you try to run the script from a network share ? or if you have scripts (local) which invoke scripts or import PowerShell modules stored on this network share ? Well you would see a security warning like below (Note - I have set execution policy as 'Unrestricted' not 'bypass' here): Run a .ps1 from the network share Well this is a similar warning, which you get when you download scripts from Internet. As the message says run Unblock-File cmdlet to unblock the script and then run it, let's try it.