So I do, as an example:
$OUs = Get-ADOrganizationalUnit <blah>
and I want to find the position in the array for “Test” (i.e. I want to do some testing where I can refer to the position in the array that “Test” is in, such as $OUs[6]).
I could do with something like:
$number = 0
foreach ($OU in $OUs)
{
"$($OU.name) - $number"
$number += 1
}
And get it that way, but I just want a quicker and easy way. I feel like I am missing something obvious.