Skip to content

Instantly share code, notes, and snippets.

@nivleshc
nivleshc / CreateADReplicaDC_DscForestWait.ps1
Created September 19, 2016 10:16
Wait for Active Directory Domain to be available
xWaitForADDomain DscForestWait
{
DomainName = $DomainName
DomainUserCredential= $DomainCreds
RetryCount = $RetryCount
RetryIntervalSec = $RetryIntervalSec
DependsOn = "[WindowsFeature]ADDSInstall"
}
@nivleshc
nivleshc / CreateADReplicaDC_ReplicaDC.ps1
Created September 19, 2016 10:19
Add Replica Domain Controller to existing Active Directory Domain
xADDomainController ReplicaDC
{
DomainName = $DomainName
DomainAdministratorCredential = $DomainCreds
SafemodeAdministratorPassword = $SafeModeAdminCreds
DatabasePath = "C:\NTDS"
LogPath = "C:\NTDS"
SysvolPath = "C:\SYSVOL"
DependsOn = "[xWaitForADDomain]DScForestWait"
}
@nivleshc
nivleshc / CreateADReplicaDC_Reboot1.ps1
Created September 19, 2016 10:21
Reboot ReplicaDC
xPendingReboot Reboot1
{
Name = "RebootServer"
DependsOn = "[xADDomainController]ReplicaDC"
}
@nivleshc
nivleshc / CreateADReplicaDC.ps1
Created September 19, 2016 10:24
DSC Configuration script to add a replica DC to an existing Active Directory Domain
Configuration CreateADReplicaDC
{
param
(
[Parameter(Mandatory)][String]$DomainName,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$Admincreds,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$SafemodeAdminCreds,
[Int]$RetryCount=20,
"repoLocation": "https://raw.githubusercontent.com/nivleshc/arm/master/",
"CreateReplicaDCPackageURL": "[concat(parameters('repoLocation'), 'CreateADReplicaDC.zip')]",
"CreateReplicaDCConfigurationFunction": "CreateADReplicaDC.ps1\\CreateADReplicaDC",
@nivleshc
nivleshc / CreateADReplicaDC_UpdateDC02Nic.json
Created September 20, 2016 06:49
ARM Template section that shows how to update the DNS settings for a VM before it is added as a replica Domain Controller. The ip address of the first DC is added as the DNS on the virtual machine
{
"name": "UpdateDC02NIC",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('nicTemplateUri')]",
"contentVersion": "1.0.0.0"
@nivleshc
nivleshc / CreateADReplicaDC_nic.json
Created September 20, 2016 07:12
Deployment Template that updates the network interface settings of a virtual machine
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"nicName": {
"type": "string",
"metadata": {
"Description": "The name of the NIC to Create or Update"
}
},
@nivleshc
nivleshc / CreateReplicaDC_ARM_Extension.json
Last active September 20, 2016 07:46
ARM Template Extension to use DSC to add a replica Domain Controller to an existing Active Directory Domain
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('DC02VMName'),'/CreateReplicaDC')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('DC02VMName'))]",
"Microsoft.Resources/deployments/UpdateDC02NIC",
"[concat('Microsoft.Compute/virtualMachines/',parameters('DC01VMName'),'/extensions/CreateADForest')]"
],
@nivleshc
nivleshc / InstallADFS_Param.ps1
Last active September 25, 2016 04:18
Parameters for InstallADFS.ps1 DSC script
Configuration InstallADFS
{
param
(
[Parameter(Mandatory)]
[string]$MachineName,
[Parameter(Mandatory)]
[string]$DomainName,
@nivleshc
nivleshc / InstallADFS_JoinDomain.ps1
Created September 25, 2016 04:31
This function inside InstallADFS joins the virtual machine to the Active Directory domain
xComputer JoinDomain
{
Name = $MachineName
DomainName = $DomainName
Credential = $DomainCreds # Credential to join to domain
DependsOn = "[xWaitForADDomain]DscForestWait"
}