I have a PowerShell script that does some checks on all Domain Admins in a number of domains. For each user account a number of checks are preformed. When one of them fails the script should go to the next admin in the list.
I currently have something like this (simplified):
Get-QADGroupMember "Domain Admins" | Select-Object SamAccountName | ForEach-Object {
#Do something
if(!ThisCheckIsOK)
{
break;
}
#Do something else
if(ThisCheckIsNotOK)
{
break;
}
...
}
This stops the whole script. Is there a way to go to the next element?
$foreach.movenext()
does not work since $foreach
is null
.