0

Anyone have experience of using the JoinDomainOrWorkgroup Method of the Win32_ComputerSystem Class?

I want to write a powershell script to join a machine to a domain. There may be an existing computer account for the machine, and if so I want to delete it and rejoin to the domain.

I've already scripted the "search and destroy" part that will delete the computer account if it exists, but just noticed the FJoinOptions switches on Technet. Trouble is - they're a bit ambiguous.

Does 4 (0x4) Deletes an account when a domain exists. mean it will delete the computer account if it already exists on the domain?

Also, can you specify the computername you want to join the machine under with this method, or should you do a rename and then join the domain.

Cheers,

Ben

NB - I've been using the guide at http://msdn.microsoft.com/en-us/library/aa392154(VS.85).aspx - not sure if there's a better resource out there.

1 Answer 1

1

It looks like this WMI method is just a wrapper around NetJoinDomain, and you'll notice that the 0x04 option isn't documented there, so I don't think it's applicable.

Looking at LMJoin.h in the Platform SDK and the docs for NetUnjoinDomain it says for NETSETUP_ACCT_DELETE 0x04 "the account is disabled when the unjoin occurs" - so it looks like the documentation team got over-zealous and it's only really applicable for unjoin operations.

For more info see the Directory Service Functions docs on MSDN.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .