Hello, I need some help please
I used this script in a LAB environment with ADDS on WinServer 2012 R2 successfully.
$Computers = get-content C:\Users\Administrator\Desktop\Servers.txt
ForEach ($Computer In $Computers) {
$DN = (Get-ADComputer -LDAPFilter "(Name=*$Computer*)").distinguishedName
If ($DN) {Set-ADObject -Identity $DN -ProtectedFromAccidentalDeletion $True}
}
When running the same script in the production environment there was a conversion failure stating that the Method is not supported
Set-ADObject : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADObject' required by parameter 'Identity'. Specified method is not supported.
At line:4 char:38
+ If ($DN) {Set-ADObject -Identity $DN -ProtectedFromAccidentalDele ...
↧
Powershell to Disable "Protect from Accidental Deletion" on List of computers
↧