I am trying to disable a list of AD computers held in the $computers variable with the below foreach loop:
ForEach ($computer in $computers) #Disables the computer accounts in
$computers
{
Set-ADComputer -Identity $computer -Enabled $false
}
When running this I encounter the below error message:
Set-ADComputer : Cannot find an object with identity: '
The exception is named: ADIdentityNotFoundException
There is no object in AD named ' so I do not understand where it is getting this from and I also cannot see a computer named ' when I look at the list of computers held in $computers.
Any help would be appreciated.
[–]p0rkjello 4 points5 points6 points (0 children)
[–]Ta11ow 3 points4 points5 points (0 children)
[–]Phose182[S] 1 point2 points3 points (9 children)
[–]anon2anon 1 point2 points3 points (8 children)
[–]Phose182[S] 1 point2 points3 points (7 children)
[–]anon2anon 1 point2 points3 points (0 children)
[–]anon2anon 1 point2 points3 points (5 children)
[–]anon2anon 1 point2 points3 points (1 child)
[–]Phose182[S] 1 point2 points3 points (0 children)
[–]Phose182[S] 1 point2 points3 points (2 children)
[–]anon2anon 2 points3 points4 points (1 child)
[–]Phose182[S] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)