I have a powershell script that remotely executes a batch script to reboot workstations and prompts the user to cancel if they need. I would like to know if I can efficiently list multiple OU's without having to repeat the execution for each OU? The following executes on the "Accounting" OU:
Do I have to list multiple identical blocks within the powershell script for each OU?
No. We don't do that in Powershell. 😉 Either you start your AD search more in the root of the OU tree and filter the computer for the given OUs. But that's a bad idea because it's not efficient. Or you create a loop and place you code inside the loop for each single OU you have in an array.