Hello,
I'm making a script in order to clean old AD object from my domain.
The script is targetting object from another domain.
So I add the "-Server" parameter to "Remove-ADObject" command in order to target the right domain but it seems to be not interpreted in the script and the command fails, saying that object not found.
In the script, the command is the following (par of a loop) :
Remove-ADObject -Server $domainname -Identity $dn -Confirm:$false
$domainname and $dn are of course defined before
However, the error displayed (like server is not read) :
+ Remove-ADObject -Identity $dn -Confirm:$false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=XXXX,OU=XXXX,DC=XXX,DC=net:ADObject) [Remove-ADObject], ADIdentityNotFoundException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Management.Commands.RemoveADObject
Any idée why is it now interpreted ?
Thanks !