Hello, I have already found a workaround using a different looping technique to complete a task I am trying to perform, but am wondering if anyone could provide some insight as to why the following fails for me.
Say I have a list of computers, in reality my list is large, but for the sake of this thread say I have an array of the names of two pcs that exist in my AD environment:
$computers="computer1","computer2"
Now, say that I only have read access on computer1, but have full access to do anything to the computer2 AD object. When I run the following command:
$computers | get-adcomputer | remove-adcomputer
It will fail on computer 1, and not continue to delete any other AD objects I have put in the list. I have tried playing with the ErrorAction variable on the remove-adcomputer command, but that does not seem to do the trick. Why is the script breaking after the first access denial and not attempting to do the rest of the pcs in the list? If i run the script against only pcs that I know i have access to modify the AD object, it works without any errors.