Created
May 20, 2015 07:56
-
-
Save Dan1el42/78a84ee720d2451f957d to your computer and use it in GitHub Desktop.
PowerShell DSC - Active Directory Domain Controller script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Configuration DCSERVER { | |
| Param ( | |
| [Parameter(Mandatory)] | |
| [PSCredential] | |
| $DomainAdministratorCredential, | |
| [Parameter(Mandatory)] | |
| [PSCredential] | |
| $SafeModeAdministratorPassword | |
| ) | |
| # Import DSC resource modules | |
| Import-DscResource -ModuleName xPSDesiredStateConfiguration | |
| Import-DscResource -ModuleName xActiveDirectory | |
| Node $AllNodes.Where{$_.Role -eq 'DomainController'}.NodeName { | |
| WindowsFeature ActiveDirectory { | |
| Name = 'AD-Domain-Services' | |
| Ensure = 'Present' | |
| } | |
| WindowsFeature RSAT-AD-Tools { | |
| Name = 'RSAT-AD-Tools' | |
| Ensure = 'Present' | |
| } | |
| WindowsFeature RSAT-ADDS { | |
| Name = 'RSAT-ADDS' | |
| Ensure = 'Present' | |
| } | |
| WindowsFeature RSAT-AD-AdminCenter { | |
| Name = 'RSAT-AD-AdminCenter' | |
| Ensure = 'Present' | |
| } | |
| WindowsFeature RSAT-ADDS-Tools { | |
| Name = 'RSAT-ADDS-Tools' | |
| Ensure = 'Present' | |
| } | |
| xADDomain CreateForest { | |
| DomainName = $Node.DomainName | |
| DomainAdministratorCredential = $DomainAdministratorCredential | |
| SafeModeAdministratorPassword = $SafeModeAdministratorPassword | |
| DatabasePath = $Node.AD_DB_Path | |
| LogPath = $Node.AD_Log_Path | |
| SysvolPath = $Node.AD_SysVol_Path | |
| DependsOn = '[WindowsFeature]ActiveDirectory' | |
| } | |
| } | |
| } | |
| $ConfigurationData = @{ | |
| AllNodes = @( | |
| @{ | |
| NodeName = 'DC01' | |
| Role = 'DomainController' | |
| DomainName = 'company.pri' | |
| AD_DB_Path = 'C:\Windows\NTDS' | |
| AD_Log_Path = 'C:\Windows\NTDS' | |
| AD_SysVol_Path = 'C:\Windows\SYSVOL' | |
| } | |
| ) | |
| } | |
| $MyDomainAdministratorCredential = Get-Credential -UserName 'DOMAIN\AdminUser' | |
| $MySafeModeAdministratorPassword = Get-Credential -UserName 'Administrator' | |
| DCSERVER -OutputPath c:\DSC\Config -ConfigurationData $ConfigurationData -DomainAdministratorCredential $MyDomainAdministratorCredential -SafeModeAdministratorPassword $MySafeModeAdministratorPassword |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment