Adding remote machine to AD via Powershell

3

So I have a powershell script, Add-Computer -ComputerName $computername -LocalCredential $computername\admin -DomainName $domain -Credential domain\$username -Force -Restart

So if I have a machine that has either fallen off the domain or is disabled, and I run the following command, I get an error: Remove-Computer : Cannot establish the WMI connection to the computer '$computername' with the following error message: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA).

Now I have verified that the machine is in fact on the network and I am able to RDP to it. IS there something wrong or will this not work if the machine is not active in AD?

windows
active-directory
domain
powershell
asked on Server Fault May 5, 2014 by Max

3 Answers

3

Figured it out, if I set-item wsman:\localhost\Client\TrustedHosts -value * on my local machine to allow remote connections from untrusted sources since certificate errors don't pop up.

And then move it into a ScriptBlock it runs.

answered on Server Fault May 6, 2014 by Max
1

Add-Computer will add the local computer to a domain : Link

You can try to add your machine using PowerShell Remoting

answered on Server Fault May 5, 2014 by NooJ
0

Assuming your machine is online make sure Remote Registry service is running and accessible, ie. disable firewall or create an exception.

answered on Server Fault May 5, 2014 by Raf

User contributions licensed under CC BY-SA 3.0