Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I filter out only the SMTP address? I want to report only on users with domain name @mydomain.com. All other domain names would be excluded. I'm attempting to run a report that would exclude certain SIP/SMTP addresses based off of the user's domain.

$CheckUser = Get-CsUser -Filter {SipAddress -eq $SIP}
  $s = 0
  While ($CheckUser -eq $null) {
    $CheckUser = Get-CsUser -Filter {SipAddress -eq $SIP}
    $s++
    If ($s -eq 2000) {
      $Date = Get-Date –f "MM/dd/yyyy HH:mm:ss"
      "[$Date] User $EUID did not complete OCS configuration"
      $ProcessedDateandTime = Get-Date
      $ProcessedDate = $ProcessedDateandTime.ToShortDateString()
      $ProcessedTime = $ProcessedDateandTime.ToShortTimeString()
      $ErrorCode = "12"
      Add-Content $ProcessedFileName "$ProcessedDate,$ProcessedTime,$EUID,Mailbox Created but OCS Timed Out.,$ErrorCode"
      Add-Content $ErrorLog "$ProcessedDate,$ProcessedTime,$EUID,Mailbox Created but OCS Timed Out."
      $FailureCount++
      Break
    }
  }
share|improve this question

What I have understood from your question is that you want to list all mailboxes who have an smtp address ending in @mydomain.com ? Like a report, with all existing @mydomain.com email addresses ?

GET-MAILBOX * | where { $_.PrimarySMTPAddress.Domain -eq 'mydomain.com' }

Source : http://www.energizedtech.com/2010/01/powershell-exchange-2007-list.html

Hope that helps

share|improve this answer

I'm not quite sure where in your above script you would post this, but you can use the [string].EndsWith operator. E.g:

dir|?{$_.name.EndsWith("f")}

will show you every item in the current directory that ends in the letter f. So you might adjust this to:

|?{$_.emailaddress.EndsWith("example.org")}

after you're doing your Get- query

? is shorthand for Where-Object (the standard filtering object for a PS pipeline).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.