# Remove-Compter : Restart doesn't work

**URL:** <https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496>\
**Category:** PowerShell Help\
**Created:** [April 24, 2014, 10:30pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496 "2014-04-24T22:30:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludovic-brient](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@ludovic-brient](https://forums.powershell.org/u/ludovic-brient)\
**Post date:** [April 24, 2014, 10:30pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/1 "2014-04-24T22:30:37Z")

</div>

Hi,  
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?

---

<div class="post-metadata">

**Author:** ![ludovic-brient](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@ludovic-brient](https://forums.powershell.org/u/ludovic-brient)\
**Post date:** [April 24, 2014, 10:32pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/2 "2014-04-24T22:32:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 24, 2014, 10:37pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/3 "2014-04-24T22:37:37Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![ludovic-brient](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@ludovic-brient](https://forums.powershell.org/u/ludovic-brient)\
**Post date:** [April 24, 2014, 10:48pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/4 "2014-04-24T22:48:28Z")

</div>

This account is domain administrator, isn’t enough?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 24, 2014, 11:53pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/5 "2014-04-24T23:53:15Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![ludovic-brient](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@ludovic-brient](https://forums.powershell.org/u/ludovic-brient)\
**Post date:** [April 25, 2014, 12:24am UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/6 "2014-04-25T00:24:18Z")

</div>

IT WORKS !!!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/remove-compter-restart-doesnt-work/2496/7 "2024-05-16T20:52:09Z")

</div>

Closed on May 16, 2024, 8:52pm UTC


