I have created a Custom action to create some "standard" sub OUs to a particular type of OU in our AD. I wanted to create a script to look in the OU you are executing against and not run again if ANY of the sub OUs exist. I want something like below but I am not sure how to get $OU to have the appropriate collection.

foreach ($child in $ou)
{
if(($child.Name -eq 'Groups') -or ($child.Name -eq 'Users') -or ($child.Name -eq 'Computer Systems'))
{$Context.ConditionIsMet = $False }
}

by (300 points)

Please log in or register to answer this question.

Related questions

I haven't seen a version to know the syntax.

asked Sep 4, 2025 by mightycabal (1.2k points)
0 votes
1 answer

I'd like to return the litigation hold attribute values if the script returns true. How can I do this?

asked Aug 26 by GronTron (390 points)
0 votes
1 answer

Is there a way to have a Scheduled Task with 4 different condition? I want to create a scheduled task start every Monday and the condition see: The next Saturday of the week ... of the week is the fifth of the month then no action Thanks in advance, Simone

asked Jan 18, 2022 by Simone.Vailati (530 points)
0 votes
1 answer

Hello Adaxes Support, I couldn't find a script to enable MessageCopyForSentAsEnabled for a shared mailbox, do you have a script for me to do that?

asked May 22, 2024 by dominik.stawny (280 points)
0 votes
1 answer

Receive "Index operation failed; the array index evaluated to null. Stack trace: at , : line 104>" and "Index operation failed; the array index evaluated to null. ... Found $GroupName, $GroupDN." } } #foreach write-output "" Write-Output "" Stop-Transcript

asked Apr 14, 2022 by jbahou (20 points)
0 votes
1 answer