Powershell and a Domain Controller met one day

I’m looking for a way to utilize Powershell in Joining a pc to a domain controller using the “IP” instead of the pc/dns name listing.
Fyi, this is being joined to the same domain again but using the fqdn instead of the proper URI to get around and reduce restarts to one (1) total. Any ideas? I dont mind using WMI, Powershell, Batch or Python if necessary. This is for a DR site domain re-join exercise to avoid manual labor… (we’re IT not cavemen!)
DNS Is still static on site…
Domain fqdn and URI function the same
AD Webservices are currently disabled… kill me
arp shows everything flattened still

Scripts used thus far require a -computername (thus a functioning Dynamic DNS…)
Examples Below

$username = Read-Host ‘Your Network Username?’
$domain = “Domain”
$DCusername = “$domain$username”
$password = Read-Host ‘What is your LAN Password?’ -AsSecureString
$credential = New-Object System.Management.Automation.PSCredential($DCusername,$password)
add-computer –domainname $domain –Credential $credential
Restart-Computer -Force

add-computer -computername -LocalCredential dradmin –domainname FQDN -Credential domain\ -restart –force -Passthru

add-computer -computername (Get-Content DRusers.txt) -LocalCredential dradmin –domainname domain -Credential domain\ -restart –force -Passthru

Add-Computer -ComputerName “Server01”, “Server02”, “localhost” -Domain “Domain02” -LocalCredential Domain01\User01 -UnjoinDomainCredential Domain01\Admin01 -Credential Domain02\Admin01 -Restart

Add-Computer -ComputerName -LocalCredential “dradmin” -DomainName “fqdn” -Credential domain\dcadmin

add-computer -computername “HYDRA2” -LocalCredential dradmin –domainname fqdn -Credential domain\ -Passthru

add-computer -computername “HYDRA2” -UnjoinDomainCredential $credential -LocalCredential dradmin -domainname “domain” -Credential $credential -Passthru

add-computer -computername “HYDRA2” -LocalCredential dradmin –domainname “domain” -Credential domain\dcadmin -Passthru

1 Like

Is -ComputerName required? Does Add-Computer -DomainName "Domain01" -Restart not work?

Yes. - computername is needed to feed a list of 130 PC’s into it for a rejoin

This would work only on if run locally on the client\host itself.

From your original post in The Lounge I thought that’s what you were going for. Plus, it’s been a minute since I’ve been on my PowerShell game :stuck_out_tongue_winking_eye:

I appreciate your time looking man. I’ve been looking for a workaround for a bit