ComputerManagementDsc icon indicating copy to clipboard operation
ComputerManagementDsc copied to clipboard

xComputer Resource should not require the computer name to join a domain

Open TravisEz13 opened this issue 8 years ago • 17 comments

xComputer Resource should not require the computer name to join a domain

TravisEz13 avatar Apr 30 '16 18:04 TravisEz13

This would be great. In my situation I have vCloud already sysprepping the machine before DSC is run so the computer name is already set. I would just like the xComputer resource to join the machine to the domain without requiring me to specify the computer name in the MOF.

theonlyway avatar May 18 '16 23:05 theonlyway

I agree, however since it's the Key is cannot be null.

So please allow the value of 'LocalHost'. Then if the value is localhost, just use $ENV:ComputerName.

That way we can host configurations on the Pull server that are consumed by many nodes and this setting will allow it to be generic. Also this will be very easy to implement.

brwilkinson avatar May 19 '16 21:05 brwilkinson

I also agree, i'm attempting to use partial configurations to join the machine to the domain and the requirement to specify the machine name is a problem. I did consider using "`$env:computername" but this falls foul of the ValidationScripts (both the regex and length).

I've created my own resource as a work around but would be nice to get it included in this resource.

danielgatley avatar May 27 '16 13:05 danielgatley

I'll try and get onto this change next week unless someone else does it first.

PlagueHO avatar May 27 '16 21:05 PlagueHO

#37 seems to address this issue.

mprahl avatar Jun 07 '16 11:06 mprahl

Excellent, thanks to all involved.

danielgatley avatar Jun 07 '16 11:06 danielgatley

The schema is still broken and requires a computer name. We should fix the schema. ComputerName should become newComputerName and not be the key.

TravisEz13 avatar Jun 16 '16 21:06 TravisEz13

The idea was that if you use the string 'Localhost' for the ComputerName, then you intend to join the domain with the current name of the computer. So the name will not be blank, you just need to update the documentation to specify the special word 'localhost' and the context that it is used.

brwilkinson avatar Jun 16 '16 21:06 brwilkinson

The problem is you could still have a configuration that says to rename the machine to 'foo' then later to 'bar' and the configuration would never converge.

TravisEz13 avatar Jun 19 '16 18:06 TravisEz13

Got the same issue. This is a blocker for me when using DSC for a domain join when using Azure Automation (AA). This as AA has a different approach in terms of compiling the MOFs.

kvaes avatar Sep 14 '16 08:09 kvaes

@kvaes This may solve your needs until the Microsoft module is sorted

theonlyway avatar Sep 14 '16 11:09 theonlyway

@theonlyway thanks! Will look into that.

kvaes avatar Sep 14 '16 11:09 kvaes

Wasn't this sorted in 1.7.0.0 - "The Name parameter resolves to $env:COMPUTERNAME when the value is localhost".

Just specify "localhost" as the name and it will use the current name.

danielgatley avatar Sep 14 '16 12:09 danielgatley

@danielgatley Please read https://github.com/PowerShell/xComputerManagement/issues/29#issuecomment-227013512

TravisEz13 avatar Sep 23 '16 23:09 TravisEz13

I vote for this

varnav avatar Apr 20 '20 20:04 varnav

I also vote for this

purduerich avatar Jan 28 '21 16:01 purduerich

I believe this configuration is already valid:

    Node localhost
    {
        Computer NewNameAndWorkgroup
        {
            Name          = 'localhost'
            WorkGroupName = 'ContosoWorkgroup'
        }

However, as Travis points out, using Name as the 'key' results in the following configuration being valid:

    Node localhost
    {
        Computer NewNameAndWorkgroup
        {
            Name          = 'Server01'
            WorkGroupName = 'ContosoWorkgroup'
        }

        Computer AnotherNewNameAndWorkgroup
        {
            Name          = 'Server02'
            WorkGroupName = 'ContosoWorkgroup'
        }
    }

This will never converge. A principle of DSC is that we need to try and prevent configurations that will not result in convergence.

I believe the schema should become:

[ClassVersion("1.0.1.0"), FriendlyName("Computer")]
class DSC_Computer : OMI_BaseResource
{
    [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance;
    [Write, Description("The desired computer name.")] String Name;
    [Write, Description("The name of the domain to join.")] String DomainName;
    [Write, Description("The distinguished name of the organizational unit that the computer account will be created in.")] String JoinOU;
    [Write, Description("Credential to be used to join a domain."), EmbeddedInstance("MSFT_Credential")] String Credential;
    [Write, Description("Credential to be used to leave a domain."), EmbeddedInstance("MSFT_Credential")] String UnjoinCredential;
    [Write, Description("The name of the workgroup.")] String WorkGroupName;
    [Write, Description("The value assigned here will be set as the local computer description.")] String Description;
    [Write, Description("The Active Directory Domain Controller to use to join the domain")] String Server;
    [Read, Description("A read-only property that specifies the organizational unit that the computer account is currently in.")] String CurrentOU;
};

Would gratefully take PRs for this one. I'm not sure when I'll get to it otherwise (5 years and counting :cry: - for that, I apologize).

Sidenote: We should add an Example showing the localhost pattern.

PlagueHO avatar Jan 28 '21 19:01 PlagueHO