Here we go again. This is just a short post on how to use the resource to join a computer to the domain. Steps we will perform:
- Download the resource from here. Follow the instructions to add it to the modules folder on you target computer.
- Create configuration data
- Build a very short configuration
Here is the configuration data we will use:
$ConfigData = @{ AllNodes = @( @{ NodeName = "*" PSDscAllowPlainTextPassword = $true } @{ NodeName = "localhost" } ); NonNodeData = @{
domainName = "try.local"
}
}
A few points to note here:
- We have a node called “*”. It is kind of a “wildcard”, however wildcards are not supported in DSC. All key/values you specify in this node, will get inherited by all nodes. That is why I do not need to specify the PSDscAllowPlainTextPassword for my node localhost.
- There is something called NonNodeData. Well as the name implies, it is configuration data that is not related specifically to any node. The data is available for all nodes. i have added the FQDN for my lab domain here.
Moving on to the configuration:
configuration DomainJoin { Param( [pscredential] $domainCred ) node $allnodes.nodename { xComputer join { Name = $allnodes.nodename DomainName = $ConfigurationData.NonNodeData.domainName Credential = $domainCred } } }
As you can see, we are using the NonNodeData in the configuration and giving the configuration the domain name to join. Here is a screenshot of the applied configuration:
That is all there is to it.
Cheers
Wont every computer this is run on be renamed to localhost?
ReplyDeleteHi,
ReplyDeleteNo, it will not. DSC may consist of 2 parts. Configuration data (input) and the configuration itself. The separation is there to be able to scale the configuration to the level you want. The configuration data specifies the input/information your configuration (DSC) needs to execute, like domain name, credentials and what else. When you compile the configuration, that is run it, you pass in the configuration containing the name of the nodes this configuration should apply to. I have specified "localhost" as one node and the xComputer DSC resource will execute on the localhost and join it to the domain "try.local" with the current computername. Hope that explains it?
Regards
Tore