daily pastebin goal
2%
SHARE
TWEET

Get the smtp alias of a mailbox on a remote Exchange server

anonit Jun 19th, 2018 133 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. <#
  2. .SYNOPSIS
  3. Get the smtp alias of a mailbox on a remote Exchange server
  4.  
  5. .DESCRIPTION
  6. Get the smtp alias of a mailbox on a remote Exchange server
  7.  
  8. .EXAMPLE
  9. ./ListSMTPAlias.ps1 -ExchUri http://anonit.net/powershell -mailbox anonit
  10.  
  11. .NOTES
  12.  
  13.  
  14. .LINK
  15. http://anonit.net
  16.  
  17. #>
  18.  
  19.  
  20. param(
  21.         [uri]$ExchUri="http://anonit.net/powershell",
  22.         [Parameter(Mandatory=$true)][string]$Mailbox
  23. )
  24.  
  25.  
  26.  
  27. $exchSession=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $exchUri -Authentication Kerberos
  28.  
  29. # Import the session, redirect the import-session command output to null to remove the output from the import (exported commands, etc)
  30. Import-PSSession $exchSession | out-null
  31. $SMTPAddresses=get-recipient -identity $Mailbox| select emailaddresses -ExpandProperty emailaddresses
  32. # The output of this command places smtp: and SMTP: infront of the email addresses, use a double replace to remove smtp: and SMTP:
  33. $SMTPAddresses.replace("smtp:","").replace("SMTP:","")
  34. # close the session
  35. Remove-PSSession $exchSession
  36.  
  37. # References https://community.spiceworks.com/scripts/show/3956-connect-to-exchange-powershell-remotely
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top