Desired State Configuration – xADDomain (Configure your domain)


It’s been a while i hadn’t publish a post on this blog. Mainly because i’m really busy at work 😉

So now, it’s time to work on a session i’ve submited for Microsoft ReBuild here in France.. This session will focus on DSC and Azure. So my first need is a Domain, i’ve looked directly in direction of xADDomain resource available in Wave kit for DSC.

The first you’ll have to check is what is need to work.


Another thing is to look about the syntax you’ll have to use in your DSC Script


Yet another thing essential is to import the custom DSC Resource !! If you don’t put this line on your script, no error will be printed on screen, but you won’t have any action initiated.


Ah, and by the way, you will have to put credential in your script, using a Get-Credential won’t do the trick  as the error bellows shows it.

If you navigate inside the link provided in the error, the solution will become very clear..

Thanks to this, you can now use this in your DSC script to create the MOF file.


Now, let’s take a look about the dependencies needed to get this MOF file Pushed sucessfully by DSC.

First , navigate to C:\Program Files\WindowsPowerShell\Modules\xActiveDirectory\DSCResources\MSFT_xADDomain\MSFT_xADDomain.ps1 and edit it.

The function for which we are looking for is named Set-TargetResource… look at what it contains… Install-ADDSDomain !! So, for our DSC script we need each Windows Features to create or adminnistrate a domain with PowerShell !

And now you can use the following script to do the job for you !

Now like always with DSC you will have to make a Start-DSCConfiguration -Path <yourpath> to apply the configuration.

I hope this will help you using and understanding DSC.

See ya !