Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. #SET COMPUTERNAME AND DESCRIPTION
  2. $computername_new = "APLAST3D-DC01"
  3. $computername_cur = $env:computername
  4. Write-host "Renaming computer..." -f Green
  5. Rename-Computer -ComputerName $computername_cur -NewName $computername_new
  6. $description = Get-WMIObject Win32_OperatingSystem
  7. Write-host "Giving a computer description..." -f Green
  8. $description.Name = "Primary DC, UK"
  9. $description.Put()
  10.  
  11.  
  12. #CONFIGURE IP SETTINGS
  13. Write-host "Configuring IP, SUBNET, GATEWAY and DNS..." -f Green
  14. $ipaddress = 172.18.5.100
  15. $ipprefix = 24
  16. $ipgw = 172.18.5.1
  17. $ipdns = 192.168.10.250
  18. $ipif = (Get-NetAdapter).ifIndex
  19.  
  20. New-NetIPAddress `
  21. -IPAddress $ipaddress `
  22. -PrefixLength $ipprefix `
  23. -InterfaceIndex $ipif `
  24. -DefaultGateway $ipgw`
  25.  
  26. Set-DnsClientServerAddress `
  27. -InterfaceIndex $ipif `
  28. -ServerAddresses $ipdns`
  29.  
  30. ###############################################
  31. ####### PC MUST REBOOT BEFORE CONTINUE ######
  32. ###############################################
  33.  
  34. #INSTALL DNS
  35. Write-host "DNS is configuring..." -f Green
  36. Install-WindowsFeature -Name DNS -IncludeManagementTools
  37. Set-DnsServerForwarder -IPAddress 192.168.10.250
  38.  
  39. #INSTALL AD
  40. Write-host "AD is installing..." -f Green
  41. Install-windowsfeature AD-Domain-Services -IncludeManagementTools
  42.  
  43. $domainname = "auto3dplast.com"
  44. $domaincomputername = $computername_new+"."+$domainname
  45.  
  46. #PROMOTE DOMAIN CONTROLLER AND CREATE FORREST
  47. Write-host "AD is configuring..." -f Green
  48. Import-Module ADDSDeployment
  49. Install-ADDSForest `
  50. -CreateDnsDelegation:$false `
  51. -DatabasePath "C:\Windows\NTDS" `
  52. -DomainMode "WinThreshold" `
  53. -DomainName $domainname `
  54. -DomainNetbiosName "AUTO3DPLAST" `
  55. -ForestMode "WinThreshold" `
  56. -InstallDns:$true `
  57. -LogPath "C:\Windows\NTDS" `
  58. -NoRebootOnCompletion:$false `
  59. -SysvolPath "C:\Windows\SYSVOL" `
  60. -Force:$true
  61.  
  62. ###############################################
  63. ####### PC MUST REBOOT BEFORE CONTINUE ######
  64. ###############################################
  65.  
  66.  
  67. #DHCP - INSTALL, CONFIGURE AND AUTENTICATE
  68. Write-host "DHCP is installing..." -f Green
  69. Install-WindowsFeature -Name dhcp -IncludeManagementTools
  70. Write-host "DHCP is configuring..." -f Green
  71. Add-DhcpServerSecurityGroup -ComputerName $domaincomputername
  72. Add-DhcpServerInDC -DnsName APLAST3D-DC01.auto3dplast.com -IPAddress $ipaddress
  73. Set-DhcpServerV4OptionValue -DnsServer $ipaddress -Router 172.18.5.1
  74. Add-DhcpServerv4Scope -Name "Employee" -StartRange $ipaddress -EndRange 172.18.5.200 -SubnetMask 255.255.255.0
  75. Add-DhcpServerv4Scope -Name "UK: Sales" -StartRange 10.10.10.1 -EndRange 10.10.10.254 -SubnetMask 255.255.255.0
  76. Add-DhcpServerv4Scope -Name "UK: Production" -StartRange 10.10.11.1 -EndRange 10.10.11.254 -SubnetMask 255.255.255.0
  77. Add-DhcpServerv4Scope -Name "UK: Customer Support" -StartRange 10.10.12.1 -EndRange 10.10.12.254 -SubnetMask 255.255.255.0
  78. Add-DhcpServerv4Scope -Name "UK: Economics Department" -StartRange 10.10.13.1 -EndRange 10.10.13.254 -SubnetMask 255.255.255.0
  79. Add-DhcpServerv4Scope -Name "UK: IT Department" -StartRange 10.10.14.1 -EndRange 10.10.14.254 -SubnetMask 255.255.255.0
  80. Add-DhcpServerv4Scope -Name "UK: Management" -StartRange 10.10.15.1 -EndRange 10.10.25.254 -SubnetMask 255.255.255.0
  81. Add-DhcpServerv4Scope -Name "UK: Research & Development" -StartRange 10.10.16.1 -Endrange 10.10.16.254 -SubnetMask 255.255.255.0
  82. Add-DhcpServerv4Scope -Name "UK: Guest wifi" -StartRange 10.10.17.1 -EndRange 10.10.17.254 -SubnetMask 255.255.255.0
  83. Add-DhcpServerv4Scope -Name "UK: printers" -StartRange 10.10.18.1 -EndRange 10.10.18.254 -SubnetMask 255.255.255.0
  84. Add-DhcpServerv4Scope -Name "UK: servers" -StartRange 10.10.19.1 -EndRange 10.10.19.254 -SubnetMask 255.255.255.0
  85. Add-DhcpServerv4Scope -Name "DK: Sales" -StartRange 10.10.20.1 -EndRange 10.10.20.254 -SubnetMask 255.255.255.0
  86. Add-DhcpServerv4Scope -Name "DK: Guest Wifi" -StartRange 10.10.21.1 -EndRange 10.10.21.254 -SubnetMask 255.255.255.0
  87. Add-DhcpServerv4Scope -Name "PL: Facility Manager" -StartRange 10.10.30.1 -EndRange 10.10.30.254 -SubnetMask 255.255.255.0
  88. Add-DhcpServerv4Scope -Name "PL: Guest Wifi" -StartRange 10.10.31.1 -EndRange 10.10.31.254 -SubnetMask 255.255.255.0
  89.  
  90. #Ignore DHCP authorization prompt (Windows Server 2016 bug)
  91. Set-ItemProperty –Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\12 –Name ConfigurationState –Value 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement