Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TravisEz13 opened this issue Apr 30, 2016 · 17 comments
Open
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.

Comments

@TravisEz13
Copy link
Contributor

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

@theonlyway
Copy link

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.

@brwilkinson
Copy link
Contributor

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.

@danielgatley
Copy link

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.

@PlagueHO
Copy link
Member

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

@mprahl
Copy link
Contributor

mprahl commented Jun 7, 2016

#37 seems to address this issue.

@danielgatley
Copy link

Excellent, thanks to all involved.

@TravisEz13 TravisEz13 added the bug The issue is a bug. label Jun 16, 2016
@TravisEz13
Copy link
Contributor Author

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

@brwilkinson
Copy link
Contributor

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.

@TravisEz13
Copy link
Contributor Author

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.

@kvaes
Copy link

kvaes commented Sep 14, 2016

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.

@theonlyway
Copy link

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

@kvaes
Copy link

kvaes commented Sep 14, 2016

@theonlyway thanks! Will look into that.

@danielgatley
Copy link

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.

@TravisEz13
Copy link
Contributor Author

@danielgatley Please read #29 (comment)

@PlagueHO PlagueHO added the help wanted The issue is up for grabs for anyone in the community. label Dec 25, 2017
@SteveL-MSFT SteveL-MSFT added this to Help Wanted in powershell/dscresources May 14, 2019
@SteveL-MSFT SteveL-MSFT removed this from Help Wanted in powershell/dscresources Nov 27, 2019
@varnav
Copy link

varnav commented Apr 20, 2020

I vote for this

@purduerich
Copy link

I also vote for this

@PlagueHO
Copy link
Member

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 😢 - for that, I apologize).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

9 participants