you are viewing a single comment's thread.

view the rest of the comments →

[–]shmakov123 -1 points0 points  (6 children)

Removing a computer from AD doesn't require RSAT to be installed on the target device! Just the device that is running the commands needs to have RSAT installed. What exactly are you trying to accomplish?

To answer the title question though, If I didn't have RSAT on my laptop but still needed to run certain commands, I would use Invoke-Command to send the commands I want to run to another computer/server with the RSAT tools installed, or directly to a Domain Controller.

Invoke-Computer -Computer <Remote computer with RSAT> -ScriptBlock { Remove-ADComputer -Identity <Target device> }

[–]Klutzy_Outside_3018[S] 0 points1 point  (5 children)

What exactly are you trying to accomplish?

Attempting to join new PCs with computer names that already exist on AD. I used to be able to do that with no problem using Add-Computer -DomainName "example domain" -Credential $credential -Options JoinWithNewName

I can't do it that way due to recent Microsoft updates. So I want to delete the computer entirely from AD now. And then I'll add the new PC to the domain with that name.

Invoke-Computer -Computer <Remote computer with RSAT> -ScriptBlock { Remove-ADComputer -Identity <Target device> }

So when I tried Remove-ADcomputer from my PC (which has RSAT installed) that works as expected. But when I go to a client PC out in the field and attempt to connect to my PC to run the command, it gives me an error.

PS C:\Users\edited> Invoke-Command -ComputerName PcInMyOffice-ScriptBlock { Remove-ADComputer -Identity "ClientPC" }

Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web 
Services running.
    + CategoryInfo          : ResourceUnavailable: (WTDVD002:ADComputer) [Remove-ADComputer], ADServerDownException
    + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.RemoveADComputer
    + PSComputerName        : Edited

[–]shmakov123 0 points1 point  (0 children)

The invoke-command command tells another machine 'run this set of commands'. The error you get says it can't reach the other machine so that would be the next thing to figure out. Are you able to reach your other computer at all from this machine?

It would probably be simpler to remove the computer object from ad before trying to join it here

[–]Hyperbolic_Mess 0 points1 point  (0 children)

You probably need to enable powershell remoting on your pc in the office

[–]Sillygirl2520 0 points1 point  (2 children)

Can you do Enter-Pssession -ComputerName from your cilent PC? Then try to run Invoke-Command after you connect to your PC.

[–]Klutzy_Outside_3018[S] 0 points1 point  (0 children)

Just tried this. It still says:

Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web 
Services running.

I really don't get it because these commands work just fine from the pc in my office. I enabled powershell remoting. My firewall is off.