##### DO NOT EDIT ##### Param( [string]$Step ) ##### DO NOT EDIT ##### if (($Step) -eq "1") { # Download and import PSM Invoke-WebRequest http://toolkit.datapipe.net/BesTasks/anthony/WindowsPSM/DPWindowsPSM.psm1 -OutFile C:\DPAutomation\DPWindowsPSM.psm1 Import-Module C:\DPAutomation\DPWindowsPSM.psm1 -Force # Step 1 - Check if AD Domain Services are already installed IF (Get-WindowsFeature AD-Domain-Services | Where-Object {$_.Installed}) { # AD Domain Services detected. Remove source files and exit. $Message = "AD DOMAIN SERVICES HAVE BEEN DETECTED. TO PROTECT YOUR SERVER, THIS SCRIPT WILL END." DPLOG -type ERROR -Message $Message Write-Host $Message Powershell Remove-Item C:\DPAutomation\ -Recurse -Force exit } $Step = "2" } if (($Step) -eq "2") { # Step 2 - Add auto resume no logon keys. Rename the server and reboot DPAddAutoResumeNoLogon -Command "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\DPAutomation\AWSNew2012DC.ps1 -Step 3" DPRenameServer -ServerName (Get-Content C:\DPAutomation\ServerName.txt) Shutdown -R -T 0 } if (($Step) -eq "3") { # Step 3 - Remove auto resume. Add auto resume no logon keys. Set AWS NTP. Set AWS Timezone. Disable Windows FW. Enable multiple RDP. Patch. Reboot. Import-Module C:\DPAutomation\DPWindowsPSM.psm1 -Force DPAWSSetNTP DPAWSSetTimezone DPDisableWindowsFW DPEnableMultipleRDP DPInstallWindowsUpdates DPRemoveAutoResumeNoLogon DPAddAutoResumeNoLogon -Command "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\DPAutomation\AWSNew2012DC.ps1 -Step 4" Shutdown -R -T 0 } if (($Step) -eq "4") { # Step 4 - Remove autoresume. Install new 2012 forest. Set DNS servers. Remove soure. Reboot. Import-Module C:\DPAutomation\DPWindowsPSM.psm1 -Force DPSetDNSServers -BaseIP (Get-Content C:\DPAutomation\AdditionalDCIP.txt) -DNS1 (Get-Content C:\DPAutomation\ExistingDCIP.txt) DPADInstallNew2012DC -DomainName (Get-Content C:\DPAutomation\DomainName.txt) -ADUsername (Get-Content C:\DPAutomation\ADUsername.txt) -ADPassword (Get-Content C:\DPAutomation\ADPassword.txt) -ADRestorePassword (Get-Content C:\DPAutomation\ADRestorePassword.txt) DPSetDNSServers -BaseIP (Get-Content C:\DPAutomation\AdditionalDCIP.txt) -DNS1 127.0.0.1 -DNS2 (Get-Content C:\DPAutomation\ExistingDCIP.txt) DPRemoveAutoResumeNoLogon Powershell Remove-Item C:\DPAutomation\ -Recurse -Force Shutdown -R -T 0 }