troubleshooting Question

How to jump to the next an Active Directory User within a ForEach statement ?

Avatar of namerg
namergFlag for United States of America asked on
Active DirectoryScripting LanguagesPowershell
32 Comments2 Solutions744 ViewsLast Modified:
Hello,

I have a foreach statement that queries/reads AD users and prompts some questions while querying the AD. If there is a question that answers No, it will have to jump to the next user.

code:
$ad = Get-ADUser -filter * -Properties sAMAccountName,sn,givenName,department,title,telephoneNumber,employeeID,employeeNumber  -SearchBase "OU=ou,DC=domain,DC=com" | Select-Object  sAMAccountName,sn,givenName,department,title,telephoneNumber,employeeID,employeeNumber

foreach ($AD_User in $ad) {
      if ($file[0].sn -eq $AD_User.sn)
      {
            #Write-Host "BINGO FOUND IT"
               #Ask Questions
              $RightWrong = Read-Host 'NOTE: Is this the right Employee, You are working on? (Y/N)'

#I AM STUCK HERE...
if $RightWrong -eq "N" {

     #It needs to jump to the next AD user and Ask questions
}
}

Thanks for your help,
ASKER CERTIFIED SOLUTION
Subash Sundharan
IT Infrastructure Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 32 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 32 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros