Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
add comment

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.