BladeFireLight / WindowsImageTools

PowerShell Tools creating and updating Windows Images
MIT License
112 stars 27 forks source link

Join account domin not always domain Joined #10

Closed drstonephd closed 5 years ago

drstonephd commented 5 years ago

We use domain trusts, so I can use my account to add machines to other domains.

Expected Behavior

I expect my domain account to be used to add the machine to the domain.

Current Behavior

An attempt will me made to use an account of the same username in the domain joined to add the machine to the domain. This account might not exist.

Possible Solution

Fortunately, the same object with the username and password also has the domain.

Current code:

$IdJoinDomainElement = $identificationElement.AppendChild($unattendXml.CreateElement('JoinDomain', 'urn:schemas-microsoft-com:unattend'))

$Null = $IdJoinDomainElement.AppendChild($unattendXml.CreateTextNode($domain))

Proposed code:

$IdJoinDomainElement = $identificationElement.AppendChild($unattendXml.CreateElement('JoinDomain', 'urn:schemas-microsoft-com:unattend'))

$Null = $IdJoinDomainElement.AppendChild($unattendXml.CreateTextNode($JoinAccount.GetNetworkCredential().Domain))

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

I've only tested in one domain and it's fine. I have not tried to join a machine to a different domain yet, but will eventually do so.

Your Environment

drstonephd commented 5 years ago

I see the update. Thanks.