Wednesday, 23 January 2013

Configure-DC1-1.ps1

  1. # Configure-DC1-1.ps1
  2. # Converts Server to DC
  3. # Version 1.0.0 - 14 Jan 2013
  4. # See http://tfl09.blogspot.com for more details
  5. # Config script block
  6. $conf = {
  7. # Install the AD - the reboot is or should be automagic
  8. Install-Windowsfeature AD-Domain-Services -IncludeManagementTools
  9. # Now install the AD to DC1
  10. $PasswordSS = ConvertTo-SecureString -string 'Pa$$w0rd' -AsPlainText -Force
  11. Install-ADDSForest -DomainName Reskit.Org -SafeModeAdministratorPassword $PasswordSS -force -InstallDNS -DomainMode Win2012 -ForestMode Win2012
  12. }
  13. # Here is start of script
  14. $Username = "DC1\administrator"
  15. $PasswordSS = ConvertTo-SecureString 'Pa$$w0rd' -AsPlainText -Force
  16. $Creddc1 = New-Object system.management.Automation.PSCredential $username,$PasswordSS
  17. # First, run a simple script block to check that the server is actually running and is the one we think it is
  18. Invoke-Command -ComputerName DC1 -ScriptBlock { ipconfig;hostname} -Credential $Creddc1 -verbose
  19. Pause
  20. # Now add create our forest/domain/dc
  21. Invoke-Command -ComputerName DC1 -Scriptblock $conf -Credential $Creddc1 -verbose
Technorati Tags: ,,,

No comments: