Wednesday, May 14, 2014

Tutorial: Configure a new domain using Active Directory with Powershell.

Introduction

In this tutorial we will install the Active Directory Domain Services and configure our first domain.The name of our domain is Connexus. We start this tutorial with a clean Windows Server 2012 R2 Standard Edition. Because we are only using Powershell scripts you could use a server core. If you are interested in the scripts just scroll down to the bottom.

Steps










Scripts

Preparations

#set static IP address
$ipaddress = "192.168.1.6"
$ipprefix = "255.255.255.0"
$ipgw = "192.168.1.1"
$ipdns = "192.168.1.6"
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"
$wmi.EnableStatic($ipaddress, $ipprefix)
$wmi.SetGateways($ipgw, 1)
$wmi.SetDNSServerSearchOrder($ipdns)
#rename the computer
$newname = "DC-Connexus-1"
Rename-Computer -NewName $newname -force
#install features
$featureLogPath = "c:\logs\featurelog.txt"
New-Item $featureLogPath -ItemType file -Force
$addsTools = "RSAT-AD-Tools"
Add-WindowsFeature $addsTools
Get-WindowsFeature | Where installed >> $featureLogPath
#restart the computer
Restart-Computer

Install Active Directory


#Install AD DS, DNS and GPMC
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools 

Configure our domain


# Create New Forest, add Domain Controller
$domainname = "CONNEXUS.HQ"
$netbiosName = "CONNEXUS"
Import-Module ADDSDeployment
Install-ADDSForest -CreateDnsDelegation:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "Win2012" `
-DomainName $domainname `
-DomainNetbiosName $netbiosName `
-ForestMode "Win2012" `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false `
-SysvolPath "C:\Windows\SYSVOL" `
-Force:$true

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.