PowerShell Logo Small

Remove-Computer



This is the built-in help made by Microsoft for the command 'Remove-Computer', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Removes the local computer from its domain.

SYNTAX


Remove-Computer [[-UnjoinDomainCredential] [<PSCredential>]] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String]>]] [-PassThru] [-Restart] [-WorkgroupName [<String>]] [-Confirm] [-WhatIf] [<CommonParameters>]
Remove-Computer [-ComputerName [<String[]>]] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String]>]] [-LocalCredential [<PSCredential>]] [-PassThru] [-Restart] [-WorkgroupName [<String>]] -UnjoinDomainCredential [<PSCredential>] [-Confirm] [-WhatIf]
[<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Remove-Computer cmdlet removes the local computer and remote computers from their current domains.


When you remove a computer from a domain, Remove-Computer also disables the computer's domain account. You must provide explicit credentials to unjoin the computer from its
domain, even when they are the credentials of the current user, and you must restart the computer to make the change effective. Also, when you remove a computer from a
domain, you must move it to a workgroup. Use the WorkgroupName parameter to specify the workgroup.


To move a computer from a workgroup to a domain, from one workgroup to another, or from one domain to another, use the Add-Computer cmdlet.


To get the results of the command, use the Verbose and PassThru parameters. To suppress the user prompt, use the Force parameter.


Remove-Computer removes the local computer and remote computers from domains. It includes credential parameters that specify alternate credentials for connecting to remote
computers, and unjoining from a domain, a Restart parameter for restarting the affected computers, and a WorkgroupName parameter for specifying the name of the workgroup to
which computers are added.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293894
Add-Computer
Checkpoint-Computer
Remove-Computer
Rename-Computer
Restart-Computer
Restore-Computer
Stop-Computer
Test-Connection

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>Remove-Computer -UnjoinDomaincredential Domain01\Admin01 -Passthru -Verbose -Restart



This command removes the local computer from the domain to which it is joined.

The command uses the UnjoinDomainCredential parameter to supply the credentials of a domain administrator. It uses the PassThru parameter and the Verbose common parameter to
display information about the success or failure of the command and the Restart parameter restart the computer, which is required to complete the remove operation.

Because the command does not specify a workgroup name, the local computer is moved to the "WORKGROUP" workgroup after it is removed from its domain.






-------------------------- EXAMPLE 2 --------------------------

PS C:\>Remove-Computer -ComputerName (Get-Content OldServers.txt) -LocalCredential Domain01\Admin01 -UnJoinDomainCredential Domain01\Admin01 -WorkgroupName Legacy -Force
-Restart



This command removes all of the computers that are listed in the OldServers.txt file from their domains and places them in the Legacy workgroup.

The command uses the LocalCredential parameter to supply the credentials of a user who has permission to connect to remote computers and the UnjoinDomainCredential parameter
to supply the credentials of a user who has permission to remove the computers from their domains. It uses the Force parameter to suppress the confirmation prompts for each
computer and the Restart parameter to restart each of the computers after it is removed from its domain.






-------------------------- EXAMPLE 3 --------------------------

PS C:\>Remove-Computer -ComputerName Server01, localhost -UnjoinDomainCredential Domain01\Admin01 -WorkgroupName Local -Restart -Force



This command removes the Server01 remote computer and the local computer from their domains and adds them to the Local workgroup. It uses the Force parameter to suppress the
confirmation prompt for each computer and the Restart parameter to restart the computers to make the change effective.