I'm trying to pretty up my code a little (and as a result learn some things)
I have a pretty straight forward problem that I would like to solve with a foreach loop
but I don't know enough about powershell yet to execute it correctly
I have this text
$gr0 = get-adgroup -Properties * -Filter "(Name -eq 'Division 0')" -SearchBase "OU=Groups,DC=solutions,DC=local";
$gr1 = get-adgroup -Properties * -Filter "(Name -eq 'Division 1')" -SearchBase "OU=Groups,DC=solutions,DC=local";
$gr2 = get-adgroup -Properties * -Filter "(Name -eq 'Division 2')" -SearchBase "OU=Groups,DC=solutions,DC=local";
I then go on to run a loop on the results of each group with identical code
what I'm trying to do is
$groups[] = $gr0 $gr1 $gr2
foreach (group in groups) { do something;}
But I can seem to find any good examples
Any help at all would be great
Thanks