Add machine to workgroup and then to Domain

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

  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 :wink:
  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

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

@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

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

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