Hello Spong,
The error message "Access is denied" indicates that the credentials you provided (or did not provide) do not have the necessary permissions to unjoin the computer from the domain.
Here's how you can attempt to resolve the issue:
Ensure Administrative Privileges: Make sure you're running PowerShell as an administrator, which you mentioned you're doing.
Provide Domain Credentials: The syntax you provided for the Remove-Computer
command appears to be incorrect for the -UnjoinDomainCredential
parameter. You should be prompted for a username and password for a domain account that has permissions to unjoin computers from the domain.
Here's the correct way to use the -UnjoinDomainCredential
parameter:
$credential = Get-Credential
Remove-Computer -UnjoinDomainCredential $credential -PassThru -Verbose -Restart
- Ensure Account Permissions: The account you use to unjoin the machine from the domain needs to have sufficient privileges. Typically, domain admins or accounts with delegated permissions to manage computer objects can perform this action. If you're unsure, consult your domain administrators or check the permissions on the computer object within Active Directory.
- Alternate Method: If you continue to face issues, you can always revert to using the traditional method by going through the System Properties -> Computer Name -> Change settings -> Change and then selecting to unjoin from the domain. This method will also require domain credentials with sufficient permissions.
If after all these steps, you're still having problems, there might be other issues at play, such as network connectivity problems, AD replication issues, or other domain-related problems that need to be investigated.