tag:blogger.com,1999:blog-24624162.post5052587165534074109..comments2023-03-17T04:31:39.011-07:00Comments on Allan's Blog: Join a domain and rename in one reboot using WMIAllanhttp://www.blogger.com/profile/11850694461776134997noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-24624162.post-87974415002472926612016-04-21T21:42:34.549-07:002016-04-21T21:42:34.549-07:00Thank you Allan, this was very helpful. Other thi...Thank you Allan, this was very helpful. Other things that I tried which was mostly variations on Rename-Computer and Add-Computer, even with the -JoinWithNewName parameter, simply did not work and always resulted in errors. This was the first approach that worked and I'll be using it in my scripts.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-24624162.post-28105102217976465502015-03-31T03:10:34.316-07:002015-03-31T03:10:34.316-07:00Thanks Alan, this was very helpful, I have been se...Thanks Alan, this was very helpful, I have been searching all over the net and couldn't find anything that worked with renaming the computer at the same time as joining the domain.Anonymoushttps://www.blogger.com/profile/08198627398086491609noreply@blogger.comtag:blogger.com,1999:blog-24624162.post-38861243102157858442014-04-19T10:07:00.744-07:002014-04-19T10:07:00.744-07:00Good! Thank you Allan
That's what I look for!
...Good! Thank you Allan<br />That's what I look for!<br />You helped me a lot!<br />Respect!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-24624162.post-42800564588777046102013-06-20T13:54:17.196-07:002013-06-20T13:54:17.196-07:00Fantastic, so we can no longer call it an undocume...Fantastic, so we can no longer call it an undocumented flag :-) Thanks!Allanhttps://www.blogger.com/profile/11850694461776134997noreply@blogger.comtag:blogger.com,1999:blog-24624162.post-59269778946299137322013-06-20T09:18:09.606-07:002013-06-20T09:18:09.606-07:00Found it!!
http://msdn.microsoft.com/en-us/librar...Found it!!<br /><br />http://msdn.microsoft.com/en-us/library/windows/desktop/aa370433(v=vs.85).aspx<br /><br />That is the underlying DLL that is called when you invoke that WMI method. It has references to all the flags you can set.<br /><br />Here's my path:<br />Googled JoinDomainOrWorkgroup 0x400 and found http://p0w3rsh3ll.wordpress.com/2013/06/04/2013-scripting-games-event-6/<br /><br />Googled NETSETUP_JOIN_WITH_NEW_NAME and found http://msdn.microsoft.com/en-us/library/windows/desktop/aa370433(v=vs.85).aspx<br /><br />Gotta love Google.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-24624162.post-528282299382211662013-06-20T08:36:31.672-07:002013-06-20T08:36:31.672-07:00It's a while ago now, so unfortunately I don&#...It's a while ago now, so unfortunately I don't remember. That flag 0x100 does sound promising, but as far as I remember I tried all the flags on that page without success. I'm sorry I didn't save the link to the page where I found the hint about the 0x400 flags (I think it was buried deep in an example on a expert-exchange.com thread, or something). Unfortunately I don't have the VM's I was using to experiment any more, so I can't test this at the moment, but I'd be very interested in hearing what you conclude. Thanks!Allanhttps://www.blogger.com/profile/11850694461776134997noreply@blogger.comtag:blogger.com,1999:blog-24624162.post-30707166913317098392013-06-20T08:05:38.528-07:002013-06-20T08:05:38.528-07:00Ah yes. My inexperience with hex....
In any case ...Ah yes. My inexperience with hex....<br /><br />In any case there is the flag 256 (0x100) which says<br /><br />"Writing SPN and DnsHostName attributes on the computer object should be deferred until the rename that follows the join."<br /><br />Have you tried this flag? I'm interested to see if it works as expected because of your undocumented findings.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-24624162.post-88404963575165522562013-06-20T07:49:23.186-07:002013-06-20T07:49:23.186-07:00Thanks for your input. Note that the flags given a...Thanks for your input. Note that the flags given above are in hex (because they start with "0x"), so the sum is 0x423, or 1059 in decimal (0x1 + 0x2 + 0x20 + 0x400 in hex is 1 + 2 + 32 + 1024 in decimal). 0x20 is correct (from the MSDN link you sent: "Allows a join to a new domain, even if the computer is already joined to a domain."). However, it does seem very likely that there's something I'm missing, since there seems to be no mention of this 0x400 flag :-)Allanhttps://www.blogger.com/profile/11850694461776134997noreply@blogger.comtag:blogger.com,1999:blog-24624162.post-80709584264561149052013-06-20T07:26:00.133-07:002013-06-20T07:26:00.133-07:00I was just passing by due to a Google search and d...I was just passing by due to a Google search and decided to comment on this post in case anyone happened upon it.<br /><br />Here is the documentation for the JoinDomainOrWorkGroup method:<br /><br />http://msdn.microsoft.com/en-us/library/windows/desktop/aa392154(v=vs.85).aspx.<br /><br />Your flag calculation is weird. There is no 400 or 20 flag, but after adding up all your flags you get 423 which does equal the sum of some of the flags from that method: 256 + 128 + 32 + 4 + 2 + 1.<br /><br />According the documentation and your flag calculation, you told the computer to deffer naming the computer account until after the rename, allow rejoining, allow joining to an existing name or create a new name, and to join a domain not a workgroup.Anonymousnoreply@blogger.com