# Add machine to workgroup and then to Domain

**URL:** <https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430>\
**Category:** PowerShell Help\
**Created:** [August 28, 2021, 2:23am UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430 "2021-08-28T02:23:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul20](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Rahul20](https://forums.powershell.org/u/Rahul20)\
**Post date:** [August 28, 2021, 2:23am UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/1 "2021-08-28T02:23:27Z")

</div>

Hello all,

Can someone please help me how can I achieve below using powershell on multiple machines

1. Join the machine to workgroup WORKGROUP
2. Use the Domain\userA credentials for the same
3. Suppress the reboot
4. Join the machine to Domain
5. Use the Domain\UserA credentials for the same
6. Restart the machine

Please help

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 28, 2021, 2:46am UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/2 "2021-08-28T02:46:23Z")

</div>

1. Why joining the workgroup at all?
2. A domain user probably does not have any rights if the pc is not joined to the domain.
3. see #1 😉
4. Use the cmdlet `Add-Computer`
5. Create a credential object prior to the cmdlet `Add-Computer` and use it then.
6. Do not use the parameter` -Restart` for the cmdlet `Add-Computer`.

Please read the help for

> **[Add-Computer (Microsoft.PowerShell.Management) - PowerShell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-computer?view=powershell-5.1)**
>
> The Add-Computer cmdlet adds the local computer or remote computers to a domain or workgroup, or moves them from one domain to another. It also creates a domain account if the computer is added to the domain without an account. You can use the...

---

<div class="post-metadata">

**Author:** ![Chen.Chen](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/chen.chen/32/1689_2.png) [@Chen.Chen](https://forums.powershell.org/u/Chen.Chen)\
**Post date:** [August 30, 2021, 1:02am UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/3 "2021-08-30T01:02:10Z")

</div>

I guess you have many clients that need to change to another domian？

---

<div class="post-metadata">

**Author:** ![Rahul20](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Rahul20](https://forums.powershell.org/u/Rahul20)\
**Post date:** [August 30, 2021, 3:07pm UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/4 "2021-08-30T15:07:56Z")

</div>

@Chen.Chen Yes, actually they are Desktop OS Citrix machines, usually called VDIs, they are unable to RDP and we use the solution of Rejoining it back to Domain to fix the issue

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 30, 2021, 3:25pm UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/5 "2021-08-30T15:25:53Z")

</div>

> [@Rahul20](#):
>
> they are unable to RDP and we use the solution of Rejoining it back to Domain to fix the issue

Wow. How about finding the root cause and fixing the actual problem instead of working around? 😉

---

<div class="post-metadata">

**Author:** ![Rahul20](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Rahul20](https://forums.powershell.org/u/Rahul20)\
**Post date:** [August 30, 2021, 9:39pm UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/6 "2021-08-30T21:39:28Z")

</div>

actually there’s a policy in place, that if a VDI is not in use for some x days, it will not be available for RDP and it needs to be domain rejoined

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/add-machine-to-workgroup-and-then-to-domain/17430/7 "2024-05-16T20:21:40Z")

</div>


