Automate a New Active Directory Forest


I really need help with my MDT deployment. I want to automate my ADD installation combined with Windows Server 2012 R2. I am using Powershell ISE to write my script and I found some guides on internet, but I still cant make it work. The only things that installs is the AD but nothing else, my scripts seems not to work at all. Can anyone see the problem.

Script 1:
#Set static IP address
$ipaddress = “”
$ipprefix = “24”
$ipgw = “”
$ipdns = “”
$ipif = (Get-NetAdapter).iflndex
New-NetIPAddress -IPAddress $ipaddress `
PrefixLength $ipprefix
InterfaceIndex $ipif -DefaultGateway $ipgw
#rename the computer
$newname = “Server”
Rename-Computer -NewName $newname -force
#install features
$featureLogPath = “c:\poshlog\featurelog.txt”
New-item $featureLogPath -itemType file -Force
$addsTools = “RSAT-AD-Tools”
Add-WindowsFeature $addsTools
Get-WindowsFeature | Where installed >> $featureLogPath
#restart the computer

Script 2:
#Install AD DS, DNS and GPMC
$featureLogPath = “c:\poshlog\feataurelog.txt”
start-job -Name addFeature -ScriptBlock {
Add-WindowsFeature -Name “ad-domain-services” -IncludeAllSubFeature -IncludeManagementTools
Add-WindowsFeature -Name “dns” -IncludeAllSubFeature -IncludeManagementTools
Add-WindowsFeature -Name “gpmc” -IncludeAllSubFeature -IncludeManagementTools }
Wait-Job -Name addFeature
Get-WindowsFeature | Where installed >>$featureLogPath

Script 3:

Create New Forest, add Domain Controller

$domainname = “something.local”
$NetbiosName = “something”
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” `

Ugh, backticks.

It’s a little hard to just statically analyze someone else’s script and guess what the problem might be ;). Are there any error messages? Have you added any commands to output status or progress? What have you done to troubleshoot these things? Do the commands/scripts work properly if you run them interactively, yourself, in a console window?