Skip to content

Instantly share code, notes, and snippets.

@nivleshc
nivleshc / CreateNewADForest.ps1
Last active September 8, 2016 07:26
DSC to create a new Active Directory Forest
Configuration CreateNewADForest {
param
#v1.4
(
[Parameter(Mandatory)]
[String]$DomainName,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$AdminCreds,
@nivleshc
nivleshc / CreateNewADForest-Parameters Explanation.ps1
Created September 8, 2016 07:22
Description of the parameters for CreateNewADForest DSC Configuration Function
$DomainName  - FQDN for the Active Directory Domain to create
$AdminCreds - a PSCredentials object that contains username and password
that will be assigned to the Domain Administrator account
$SafeModeAdminCreds - a PSCredentials object that contains the password that will
be assigned to the Safe Mode Administrator account
$myFirstUserCreds - a PSCredentials object that contains the username and
password for the first domain user account to create
$RetryCount - defines how many retries should be performed while waiting
for the domain to be provisioned
$RetryIntervalSec - defines the seconds between each retry to check if the
@nivleshc
nivleshc / Extensions_CreateNewADForest.json
Last active September 8, 2016 07:32
Azure Resource Manager Template to create a new Active Directory Forest
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('DC01Name'),'/CreateNewADForest')]",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('DC01Name'))]"
],
"tags": {
@nivleshc
nivleshc / ScriptPart_CreateNewADForest_DomainCreds.ps1
Created September 8, 2016 07:37
This is a part of the CreateNewADForest DSC Configuration function. It defines a new PSCredential object in the domain\user format
[System.Management.Automation.PSCredential]$DomainCreds = New-Object System.Management.Automation.PSCredential ("${DomainName}\$($Admincreds.UserName)", $Admincreds.Password
@nivleshc
nivleshc / ScriptPart_CreateNewADForest_xADDomain_FirstDC.ps1
Created September 8, 2016 07:41
Part of the CreateNewADForest DSC configuration script that adds the first domain controller
xADDomain FirstDC
{
DomainName = $DomainName
DomainAdministratorCredential = $DomainCreds
SafemodeAdministratorPassword = $SafeModeAdminCreds
DatabasePath = "C:\NTDS"
LogPath = "C:\NTDS"
SysvolPath = "C:\SYSVOL"
DependsOn = "[WindowsFeature]ADDSInstall","[xDnsServerAddress]DnsServerAddress"
}
@nivleshc
nivleshc / TemplatePart_CreateNewADForest_Excerpt1.json
Last active September 26, 2016 11:19
Excerpt of CreateNewADForest.json showing the parameter declarations used in the CreateNewADForest extension
"repoLocation": "https://raw.githubusercontent.com/nivleshc/arm/master/",
"CreateNewADForestPackageURL": "[concat(variables('repoLocation'), 'CreateNewADForest.zip')]",
"CreateNewADForestConfigurationFunction": "CreateNewADForest.ps1\\CreateNewADForest",
@nivleshc
nivleshc / CreateADReplicaDC_Param.ps1
Created September 19, 2016 09:52
Parameters for CreateADReplicaDC DSC Configuration Script
Configuration CreateADReplicaDC
{
param
(
[Parameter(Mandatory)]
[String]$DomainName,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$Admincreds,
@nivleshc
nivleshc / CreateADReplicaDC_Import.ps1
Created September 19, 2016 10:00
Importing the downloaded modules
Import-DscResource -ModuleName xActiveDirectory, xPendingReboot
@nivleshc
nivleshc / CreateADReplicaDC_LocalConfigurationManager.ps1
Created September 19, 2016 10:11
LocalConfigurationManager settings for CreateADReplicaDC
LocalConfigurationManager
{
ActionAfterReboot = 'ContinueConfiguration'
ConfigurationMode = 'ApplyOnly'
RebootNodeIfNeeded = $true
}
@nivleshc
nivleshc / CreateADReplicaDC_RSAT.ps1
Created September 19, 2016 10:13
Installing Remote Server Administration Tools
WindowsFeature RSAT
{
Ensure = "Present"
Name = "RSAT"
}