🕫 NEW 🕫- Kaseya Certified Expert Training Camp launches on 8/23. Class size is limited. Learn more > https://www.community.connectit.com/events/28-kaseya-certified-expert-traincamp-august-23rd-september-2nd

Join/Quit Windows Domain

Kaseya Automation Team
Kaseya Automation Team USMember, Kaseya Certified CHOCOLATE MILK
edited January 24 in Solutions

Product Name: Join/Quit Windows Domain

Description : This set of agent procedures allows you to add or remove any endpoints to your Windows Domain.
There are two versions of each script. One prompting you for the credentials and domain name prior to executing so you can fill as needed.
The second version uses static variables you will need to modify with the correct credentials for better automation.

Instructions :

Upload the procedure with the Import Folder/Procedure tool in the Agent Procedures module under Schedule / Create


  • DmitrijKondrasov
    DmitrijKondrasov Vilnius, LithuaniaMember, Managed Service Provider
    edited November 2019

    Is it possible to join pc to not default OU?

  • Gareth Thorley
    Gareth Thorley Member CHOCOLATE MILK
    edited November 2019

    If you want the PC to join a specific OU, you could add the following parameter, to line 7 of the Agent Procedure

    -OUPATH "OU=Tills,OU=Store Devices,OU=Domain Operations,DC=YourDomain,DC=local"

    If you want to specify your own OU, you will need to create additional GetVariable lines, and then reference the variable in Line 7.

    Hope this helps!

  • Nick Abdullah
    Nick Abdullah Member CHOCOLATE MILK
    edited February 2021

    Where is the joindomain.ps1 file?

  • Rob Allison
    Rob Allison Member CHOCOLATE MILK

    the joindomain.ps1 file is being created during the procedure execution. See the lines about echo.

  • Rob Allison
    Rob Allison Member CHOCOLATE MILK

    I had to edit the script to include the domain variable in front of the username so it would join Windows 10 PCs to the domain. Without this the scrip runs but the PC does not join the domain. Can get around this but you end up putting the domain in twice so by doing this I take advantage of the prompts fields.

    echo UserName = "#admin# -> echo UserName = '#domain#\#admin#'

  • Andrew Rathkopf
    Andrew Rathkopf Member CHOCOLATE MILK

    Sorry I'm a little new to this . What would I make line 7 look like if I wanted it to join the domain and put it in a specific OU.

    Line 7 currently looks like this:

    echo Add-Computer -DomainName '#domain#' -Credential $creds -Restart -Force >>>> #vAgentConfiguration.agentTempDir#\JoinDomain.ps1

    Would this be it:

    echo Add-Computer -DomainName '#domain#' -OUPath=MDM,DC=mydomain,DC=local-Credential $creds -Restart -Force >>>> #vAgentConfiguration.agentTempDir#\JoinDomain.ps1