All very easy with Windows PowerShell ...
New-Computer -Domain home.lab -Credential HOME\Administrator -Restart
Provide the password when prompted and wait for the machine to restart.
Easy easy easy .....
New-Computer -Domain home.lab -Credential HOME\Administrator -Restart
Get-NetAdapter
Get-NetAdapter Results |
New-NetIPAddress -IPAddress 192.168.33.10 ` -Default Gateway 192.168.33.1 ` -AddressFamily IPv4 ` -PrefixLength 24 ` -InterfaceIndex 19
New-NetIPAddress Results |
Set-DnsClientServerAddress ` -ServerAddress 192.168.33.2 ` -InterfaceIndex 19
Rename-Computer -NewName LABSVR2 -Restart
netsh advfirewall firewall add rule name="SQL Server 1433" dir=in action=allow protocol=TCP localport=1433
Default auditing on the root of a W2K12 Active Directory |
Auditing on the root of the domain after the script has run |
#------------------------------------------------------ # | File : ADDSAuditSettings.ps1 # | # | Purpose : Configures extra auditing (SACLs) at for the # | new domain # | # | Usage : PowerShell.exe -FILE .\ADDSAuditSettings.ps1 #------------------------------------------------------ # | # | Author: JustAnotherTechnicalBlog # | Creation Date: 26 April 2013 # | # | # | Maintenance History # | ------------------- # | # | Version: 1.00 2013-04-26 Initial Version JustAnotherTechnicalBlog # | # | #------------------------------------------------------ # Clear the error variable #------------------------------------------------------ $error.clear() # Import the ActiveDirectory PowerShell Module if required #------------------------------------------------------ if (-not (Get-Module ActiveDirectory)) { Import-Module ActiveDirectory } # This fuction takes a schema GUID ID and a security # principal and enables a new SACL entry so deletions # of target object type by the specified security # principal will be audited #------------------------------------------------------ Function AuditDeletions { Param ( [Parameter(Mandatory=$true)] [system.guid]$SchemaIDGUID, [Security.Principal.NTAccount]$SecurityPrincipal ) # Get the DN for the current domain #------------------------------------------------------ $dn = (Get-ADDomain).DistinguishedName # Get the current ACLs for the root of the domain #------------------------------------------------------ $acl = Get-ACL -Audit -Path AD:\$dn # Build the new SACL rule. # This rule will enable auditing of succesful deletion # of our target object. The rule will be inherited # throughout the domain #------------------------------------------------------ $Rule = New-Object System.DirectoryServices.ActiveDirectoryAuditRule ` $SecurityPrincipal, ` "DeleteChild", ` "Success", ` $SchemaIDGUID, ` "All" # Add the new audit rule to the ACL we # opened earlier #------------------------------------------------------ $acl.AddAuditRule($Rule) # Commit the new audit rule #------------------------------------------------------ Set-ACL -Path AD:\$dn -AclObject $acl } # To work with AD objects we need the relevent schema # ID GUIDs. variables to hold these: #------------------------------------------------------ $ComputerSchemaIDGUID = "bf967a86-0de6-11d0-a285-00aa003049e2" $GroupSchemaIDGUID = "bf967a9c-0de6-11d0-a285-00aa003049e2" $UserSchemaIDGUID = "bf967aba-0de6-11d0-a285-00aa003049e2" # The AuditDeletions function above requires a security # principal. user/group we want to audit? #------------------------------------------------------ $who = "Everyone" # Put the AuditDeletions function to use .... #------------------------------------------------------ AuditDeletions $ComputerSchemaIDGUID $who AuditDeletions $GroupSchemaIDGUID $who AuditDeletions $UserSchemaIDGUID $who # Basic error handling #------------------------------------------------------ If ($error) { Write-Host "Audit setting configurations failed" Exit 1003 } Else { Write-Host "Audit setting configurations completed OK" }
#------------------------------------------------------------------- # | File : NewChildDomain.ps1 # | # | Purpose : Installs the first Domain Controller in a child domain, # | thus creating the new domain # | - Designed to be run from a Configuration Manager OSD # | task sequence # | - Designed for Windows Server 2012 environments # | - Reboot handled by task sequence # | # | Usage : PowerShell.exe -FILE .\NewChildDomain.ps1 #------------------------------------------------------------------- # | # | Author: JustAnotherTechnicalBlog # | Creation Date: 23 April 2013 # | # | # | Maintenance History # | ------------------- # | # | Version: 1.00 2013-04-23 Initial Version JustAnotherTechnicalBlog # | # | #------------------------------------------------------------------- # Clear the error variable #------------------------------------------------------------------- $error.clear() # Import the ActiveDirectory PowerShell Module if required #------------------------------------------------------------------- if (-not (Get-Module ActiveDirectory)) { Import-Module ActiveDirectory } # Here we get access to the Task Sequence variables #------------------------------------------------------------------- $objTSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment # Grab the data we need from the task sequence variables #------------------------------------------------------------------- $strTSNetBIOSName = $objTSenv.Value("RoleVariable1") $strTSDomainName = $objTSenv.Value("RoleVariable2") $strTSPrntNBName = $objTSenv.Value("RoleVariable3") $strTSPrntDmnName = $objTSenv.Value("RoleVariable4") $strTSPrntDmnAcct = "$strTSPrntNBName\" + $objTSenv.Value("RoleAccount2") $strTSDNSAccount = "$strTSPrntNBName\" + $objTSenv.Value("RoleAccount3") # Convert our password to the data type required by Install-ADDSDomain #------------------------------------------------------------------- $secstrSafeModePassword = $objTSenv.Value("RoleAccountPassword1") | ` ConvertTo-SecureString -asPlainText -Force # Convert our accounts and passwords strings to the data type required # by Install-ADDSDomain #------------------------------------------------------------------- $secstrDomainPassword = $objTSenv.Value("RoleAccountPassword2") | ` ConvertTo-SecureString -asPlainText -Force $DomainCreds = New-Object ` System.Management.Automation.PSCredential("$strTSPrntDmnAcct",$secstrDomainPassword) $secstrDNSPassword = $objTSenv.Value("RoleAccountPassword3") | ` ConvertTo-SecureString -asPlainText -Force $DNSCreds = New-Object ` System.Management.Automation.PSCredential("$strTSDNSAccount",$secstrDNSPassword) # Install our first forest Domain Controller, creating a new forest #------------------------------------------------------------------- Install-ADDSDomain ` -Force ` -NoRebootOnCompletion ` -CreateDNSDelegation ` -DomainType Child ` -DomainMode Win2012 ` -ParentDomainName "$strTSPrntDmnName" ` -NewDomainNetBIOSName "$strTSNetBIOSName" ` -NewDomainName "$strTSDomainName" ` -SafeModeAdministratorPassword $secstrSafeModePassword ` -DNSDelegationCredential $DNSCreds ` -Credential $DomainCreds # Basic error handling #------------------------------------------------------------------- If ($error) { Write-Host "Child domain creation failed" Exit 1001 } Else { Write-Host "Child domain created successfully"
Task Sequence Snippet: Active Directory Installation |
Installing an Active Directory Child Domain with Windows PowerShell |
#----------- PowerShell.exe -COMMAND Install-WindowsFeature -Name AD-Domain-Services ` -IncludeManagementToolsThe code above does not create an domain controller. It just installs the Active Directory Domain Services role. Other steps in the task sequence see the server promoted to be a domain controller.
Task Sequence Snippet: Active Directory Installation |
Installing the Active Directory Domain Services Role with Windows PowerShell |
#------------------------------------------------------------------------------------ # | File : NewForest.ps1 # | # | Purpose : Installs the first Domain Controller in a forest, thus creating # | a new forest # | - Designed to be run from a Configuration Manager OSD task sequence # | - Designed for Windows Server 2012 environments # | - Reboot handled by task sequence # | # | Usage : PowerShell.exe -FILE .\NewForest.ps1 #------------------------------------------------------------------------------------ # | # | Author: JustAnotherTechnicalBlog # | Creation Date: 11 April 2013 # | # | # | Maintenance History # | ------------------- # | # | Version: 1.00 2013-04-12 Initial Version JustAnotherTechnicalBlog # | # | #------------------------------------------------------------------------------------ # Clear the error variable #------------------------------------------------------------------------------------ $error.clear() # Import the ActiveDirectory PowerShell Module if required #------------------------------------------------------------------------------------ if (-not (Get-Module ActiveDirectory)) { Import-Module ActiveDirectory } # Here we get access to the Task Sequence variables #------------------------------------------------------------------------------------ $objTSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment # Grab the data we need from the task sequence variables #------------------------------------------------------------------------------------ $strTSNetBIOSName = $objTSenv.Value("RoleVariable1") $strTSDomainName = $objTSenv.Value("RoleVariable2") # Convert our password to the data type required # by Install-ADDSForest #------------------------------------------------------------------------------------ $secstrSafeModePassword = $objTSenv.Value("RolePassword1") | ` ConvertTo-SecureString -asPlainText -Force # Install our first forest Domain Controller, creating a new forest #------------------------------------------------------------------------------------ Install-ADDSForest ` -Force ` -NoRebootOnCompletion ` -DomainNetBIOSName "$strTSNetBIOSName" ` -DomainName "$strTSDomainName" ` -ForestMode Win2012 ` -DomainMode Win2012 ` -SafeModeAdministratorPassword ` $secstrSafeModePassword # Very basic error handling ... #------------------------------------------------------------------------------------ If ($error) { Write-Host "Forest creation failed" Exit 1000 } Else { Write-Host "Forest created successfully" }
Task Sequence Snippet: Active Directory Installation |
Installing a new forest with a PowerShell script |