I was tasked to develop a PS script to remove machines from the domain for automation purposes. I am not a full time scripter so i went ahead and did some digging and found this :
"Remove-Computer -UnjoinDomaincredential nsmg\svc_unjoindomain -PassThru -Verbose -Restart -force"
when i run it on my test computer that is currently joined to my company computer i get this error: "Remove-Computer : Failed to unjoin computer 'TX0001QVE7P8I' from domain 'X' with the following error message: Access is denied. At line:1 char:1
- Remove-Computer -UnjoinDomaincredential DOMAIN1/DOMAIN ADMIN -PassTh ...
-
+ CategoryInfo : OperationStopped: (TX0001QVE7P8I:String) [Remove-Computer], InvalidOperationException + FullyQualifiedErrorId : FailToUnjoinDomain,Microsoft.PowerShell.Commands.RemoveComputerCommand"
I have replaced the syntax to match my domain as well as gave it a domain admin account but still getting this error. could you guys tell me what i could possibly be missing?