Skip to main content

Is it possible to create a worklet that will join a workstation to a corperate domain?  Has anyone attempted this before?

This should be possible using the Add-Computer command and leveraging parameters like
-DomainName
-Credential
-LocalCredential
and -OUPath.
(MS Reference)


Was anyone able to do this successfully through Automox?  If so, could you share the script?


This would be very helpful command


This may work.

 

# Define variables
$domain = "yourdomain.com"
$username = "administrator"
$password = "YourPassword"
$computerName = "YourComputerName"

# Securely convert password to a secure string
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force

# Create credentials object
$credentials = New-Object System.Management.Automation.PSCredential($username, $securePassword)

# Join the computer to the domain
Add-Computer -DomainName $domain -Credential $credentials -ComputerName $computerName -Restart
 

 


Reply