Powershell to pull out user with specific email address in them


posted by Krishna
07-22-2009

Downloads: 446
File size: 518 B
Views: 5,386

Embed
Powershell to pull out user with specific email address in them
  1. Get-Mailbox -ResultSize Unlimited |  select DisplayName, Alias |export-csv C:\stats.csv 
  2. $csv = Import-csv -path "C:\stats.csv" 
  3. foreach($line in $csv
  4. {  
  5.     $result = $Line.Alias 
  6.     $Emailadd = Get-Mailbox $Line.Alias |select emailaddresses 
  7.     $K = $Emailadd.EmailAddresses 
  8.  
  9.      foreach ($S in $K
  10.      
  11.           If (($S.smtpaddress -like "*domain001.fr") -or ($S.smtpaddress -like "*@domain001.com")) 
  12.           
  13.                $result = $result + "," + $S.smtpaddress 
  14.           
  15.      
  16.      $result | Out-File C:\Result_output.csv -Append 
  17.  

Powershell to pull out user with specific email address in them

 

Copyright 2012 PowerShell.com. All rights reserved.