标签:alter effective pow http button disable work nbsp alt
Remove-Computer [-UnjoinDomainCredential] <PSCredential> [-LocalCredential <PSCredential>] [-Restart] [-ComputerName <String[]>] [-Force] [-PassThru] [-WorkgroupName <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
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 from its domain, even when they are the credentials of the current user. 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.
Example 1: Remove the local computer from its domain
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: Move several computers to a legacy workgroup
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 includes 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: Remove computers from a workgroup without confirmation
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.
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
标签:alter effective pow http button disable work nbsp alt
原文地址:https://www.cnblogs.com/oskb/p/9370910.html