Remove computer from join with PowerShell

Source: Internet
Author: User

Removes the local computer from its domain.
remove-Computer      [-unjoindomaincredential] <PSCredential>      [-localcredential < Pscredential>]      [-Restart]      [-computername <String[]>]      [-  Force]      [-PassThru]      [-workgroupname <String>]      [-WhatIf]      [-Confirm]      [<commonparameters>]
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 domain account of the computer. You must provide explicit credentials to unjoin the computer in the IT domain, even when they is the credentials of the CU Rrent user. You must restart the change effective of the computer to make. 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 with the Force parameter.

Remove-computer removes the local computer and remote computers from domains. IT includes credential parameters specify alternate credentials for connecting to remote computers, and unjoining fro m a domain, a Restart parameter for restarting the affected computers, and a workgroupname parameter for Specifying the name of the workgroup to which computers is added.

Examples

Example 1:remove The local computer from its domain

PowerShell Replication
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 Remo ve operation.

Because The command does not specify a workgroup name, the local computer was moved to the workgroup workgroup after it was Removed from its domain.

Example 2:move Several computers to a legacy workgroup

PowerShell Replication
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 is listed in the OldServers.txt file from their domains and includes them In the Legacy workgroup.

The command uses the localcredential parameter to supply the credentials of a user who have permission to connect To remote computers and the unjoindomaincredential parameter to supply the credentials of a user who have Permissi On to remove the computers from their domains. It uses the parameter to suppress the confirmation prompts for each computer and the Restart param Eter to restart each of the computers after it was removed from its domain.

Example 3:remove computers from a workgroup without confirmation

PowerShell Replication
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 wor Kgroup. It uses the parameter to suppress the confirmation prompt for each computer and the Restart parame ter to restart the computers to make the change effective.

Refer:

https://docs.microsoft.com/zh-cn/powershell/module/Microsoft.PowerShell.Management/Remove-Computer?view=powershell-5.1

Https://ss64.com/ps/remove-computer.html

Remove computer from join with PowerShell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.