Please help!

There is the following code:

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = "LDAP://dc=dc,dc=ru" $objSearcher.Filter = "(&(objectCategory=person)(!userAccountControl:1.2.840.113556.1.4.803:=2))" $users = $objSearcher.FindAll() $users | ForEach-Object { $user = $_.Properties New-Object PsObject -Property @{ Человек = [string]$user.mail Кто = [string]$user.title } } | Export-Csv -NoClobber -Encoding utf8 -Path C:\list_user.csv 

It is necessary to add a condition: to export mail and title only to those persons whose $ user.mail is in a number of mails (about 300). I tried to add to the above code

 | where-object {$_.user.mail in "A.Zenina@dc.ru, Vasiliy.Ivanovich@dc.ru, Evgeniya.Zaiteeva@dc.ru"} 

but to no avail.

  • and what place did you try to add? - Senior Pomidor
  • In the end. Where to? - Regina
  • $users | where-object {$_ ... } | ForEach-Object { $users | where-object {$_ ... } | ForEach-Object { and tried? - Senior Pomidor
  • @SeniorPomidor tried. gives empty fields, and their number (also added $ users.Count) is the same as without the where-object. And these addresses are exactly in the specified by me branch. - Regina
  • Try $mails = "A.Zenina@dc.ru", "Vasiliy.Ivanovich@dc.ru", "Evgeniya.Zaiteeva@dc.ru" \n $users | where-object {$mails -contains $_.user.mail} | ForEach-Object { $mails = "A.Zenina@dc.ru", "Vasiliy.Ivanovich@dc.ru", "Evgeniya.Zaiteeva@dc.ru" \n $users | where-object {$mails -contains $_.user.mail} | ForEach-Object { $mails = "A.Zenina@dc.ru", "Vasiliy.Ivanovich@dc.ru", "Evgeniya.Zaiteeva@dc.ru" \n $users | where-object {$mails -contains $_.user.mail} | ForEach-Object { - Senior Pomidor

0