Remove-Computer is a Windows PowerShell command used to remove a computer from its current domain or workgroup. It is a useful tool for system administrators who need to manage multiple computers in a network. This command can be used to remove a computer from a domain, workgroup, or local computer. It can also be used to delete a computer from the Active Directory.
The Remove-Computer command is a part of the Windows PowerShell module for managing computers. It is available in Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2012, and Windows Server 2016. It is also available in Windows PowerShell 5.0 and later.
Syntax
The syntax of the Remove-Computer command is as follows:
Remove-Computer [-UnjoinDomainCredential] [-UnjoinDomain] [-Force] [-PassThru] [-ComputerName] [-Credential] [-LocalCredential] [-WorkgroupName] [-Restart] [-Confirm] [-WhatIf] [-Domain] [-OUPath] [-Server] [-NewName] [-Force] [-PassThru] [-ComputerName] [-Credential] [-LocalCredential] [-WorkgroupName] [-Restart] [-Confirm] [-WhatIf] [-Domain] [-OUPath] [-Server] [-NewName] [-Force] [-PassThru] [-ComputerName] [-Credential] [-LocalCredential] [-WorkgroupName] [-Restart] [-Confirm] [-WhatIf] [-Domain] [-OUPath] [-Server] [-NewName] [-Force] [-PassThru] [-ComputerName] [-Credential] [-LocalCredential] [-WorkgroupName] [-Restart] [-Confirm] [-WhatIf] [-Domain] [-OUPath] [-Server] [-NewName]
Parameters
The Remove-Computer command has the following parameters:
Parameter | Description |
---|---|
UnjoinDomainCredential | Specifies the credentials used to unjoin the computer from the domain. |
UnjoinDomain | Specifies whether to unjoin the computer from the domain. |
Force | Specifies whether to forcibly remove the computer from the domain. |
PassThru | Specifies whether to return the object representing the computer. |
ComputerName | Specifies the name of the computer to be removed. |
Credential | Specifies the credentials used to authenticate the user. |
LocalCredential | Specifies the credentials used to authenticate the user on the local computer. |
WorkgroupName | Specifies the name of the workgroup to which the computer will be added. |
Restart | Specifies whether to restart the computer after it is removed from the domain. |
Confirm | Specifies whether to prompt the user for confirmation before removing the computer from the domain. |
WhatIf | Specifies whether to simulate the removal of the computer from the domain. |
Domain | Specifies the name of the domain from which the computer will be removed. |
OUPath | Specifies the path of the organizational unit from which the computer will be removed. |
Server | Specifies the name of the server to which the computer will be removed. |
NewName | Specifies the new name of the computer. |
Inputs
The Remove-Computer command accepts the following input types:
- System.String
- System.Management.Automation.PSCredential
- System.Management.Automation.Credential
Outputs
The Remove-Computer command returns the following output types:
- System.Object
- System.Management.Automation.PSObject
Examples
The following example shows how to remove a computer from a domain:
Remove-Computer -ComputerName “Computer1” -Domain “Domain1” -Credential “Domain1\Administrator” -Force
The following example shows how to remove a computer from a workgroup:
Remove-Computer -ComputerName “Computer1” -WorkgroupName “Workgroup1” -LocalCredential “Administrator” -Force
Tips
Here are some tips for using the Remove-Computer command:
- Make sure you have the necessary permissions to remove the computer from the domain or workgroup.
- If you are removing a computer from a domain, you must specify the credentials of a user with permissions to unjoin the computer from the domain.
- If you are removing a computer from a workgroup, you must specify the credentials of a user with permissions to unjoin the computer from the workgroup.
- If you are removing a computer from a domain, you can use the -Restart parameter to restart the computer after it is removed from the domain.
- If you are removing a computer from a workgroup, you can use the -Restart parameter to restart the computer after it is removed from the workgroup.
- If you are removing a computer from a domain, you can use the -WhatIf parameter to simulate the removal of the computer from the domain.
- If you are removing a computer from a workgroup, you can use the -WhatIf parameter to simulate the removal of the computer from the workgroup.
- If you are removing a computer from a domain, you can use the -Confirm parameter to prompt the user for confirmation before removing the computer from the domain.
- If you are removing a computer from a workgroup, you can use the -Confirm parameter to prompt the user for confirmation before removing the computer from the workgroup.
- If you are removing a computer from a domain, you can use the -NewName parameter to specify the new name of the computer.
Conclusion
The Remove-Computer command is a useful tool for system administrators who need to manage multiple computers in a network. It can be used to remove a computer from a domain, workgroup, or local computer. It can also be used to delete a computer from the Active Directory. The command has several parameters that can be used to customize the removal process, such as the -Force parameter to forcibly remove the computer from the domain, the -Restart parameter to restart the computer after it is removed from the domain, and the -NewName parameter to specify the new name of the computer.