Author Posts

May 19, 2015 at 2:47 pm

Hello – I am trying to build out a new domain using WMF 5 DSC and failing. Most of the errors that I am getting are about resources not existiing (IE: xADdomain) which if I import it finds that. But now I am getting that it can't find createforest.


#IMPORT REQUIRED MODULES
Import-Module xPSDesiredStateConfiguration
Import-Module xActiveDirectory

configuration DCSERVER {
Node $computername {

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 =
SafeModeAdministratorPassword =
DatabasePath = $Node.AD_DB_Path
LogPath = $Node.AD_Log_Path
SysvolPath = $Node.AD_SysVol_Path
DependsOn = '[WindowsFeature]ActiveDirectory'

}

}

}

$computername = 'localhost'
DCSERVER -OutputPath c:\DSC\Config

May 19, 2015 at 4:08 pm

These are the error I am getting

PS C:\Users\Administrator\Documents> C:\Users\Administrator\Documents\DCDSC.ps1
PSDesiredStateConfiguration\Node : The term 'xActiveDirectory\xADDomain' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Administrator\Documents\DCDSC.ps1:11 char:5
+ Node $computername {
+ ~~~~
+ CategoryInfo : ObjectNotFound: (xActiveDirectory\xADDomain:String) [PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException,PSDesiredStateConfiguration\node

WARNING: The configuration 'DCSERVER' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource –ModuleName 'PSDesiredStateConfiguration
' to your configuration to avoid this message.
Errors occurred while processing configuration 'DCSERVER'.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:3483 char:5
+ throw $ErrorRecord
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (DCSERVER:String) [], InvalidOperationException
+ FullyQualifiedErrorId : FailToProcessConfiguration

May 19, 2015 at 11:53 pm

Import-Module does not work here. Microsoft has created a new cmdlet Import-DscResource which only works within a Configuration block. I have refactored your Configuration script to put you back on the right path.

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