Author Posts

April 25, 2014 at 4:00 am

i want to use the command Remove-Computer to unjoin computers from domain.
I use this command :

Remove-Computer  -UnjoinDomainCredential C_NET\Administrateur -ComputerName VSMW0020 -Force -Restart

Unjoin domain works, but not the restart :

Remove-Computer : Impossible de redémarrer l'ordinateur VSMW0020 avec le message d'erreur suivant : Accès refusé .
Au caractère Ligne:1 : 1
+ Remove-Computer -UnjoinDomainCredential C_NET\Administrateur -ComputerName VSMW ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (VSMW0020:String) [Remove-Computer], InvalidOperationException
+ FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Commands.RemoveComputerCommand

Can someone help?

April 25, 2014 at 4:02 am

Command launched from a 2K8 R2 with powerhsell V3, targeted computers are XP and Win7

April 25, 2014 at 4:07 am

It's an Access Denied error. Is the account that's running the command also an administrator on the target computer? If not, you'll also need to use the -LocalCredential parameter in addition to -UnjoinDomainCredential. (You can pass the same credentials to both parameters, if appropriate.)

April 25, 2014 at 4:18 am

This account is domain administrator, isn't enough?

April 25, 2014 at 5:23 am

Which account? There are two sets of credentials in play, in the original command you posted. C_NET\Administrateur is used to connect to the domain controller and perform that part of the unjoin process. To connect to the VSMW0020 computer, though, the cmdlet is just using the credentials of whatever user is logged on and running the command. To use the C_NET\Administrateur account for both parts of the operation, you'd do something like this:

$cred = Get-Credential C_NET\Administrateur
Remove-Computer  -UnjoinDomainCredential $cred -LocalCredential $cred -ComputerName VSMW0020 -Force -Restart

April 25, 2014 at 5:54 am

IT WORKS !!!!!!!!!!!!!!!