Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- Get the smtp alias of a mailbox on a remote Exchange server
- .DESCRIPTION
- Get the smtp alias of a mailbox on a remote Exchange server
- .EXAMPLE
- ./ListSMTPAlias.ps1 -ExchUri http://anonit.net/powershell -mailbox anonit
- .NOTES
- .LINK
- http://anonit.net
- #>
- param(
- [uri]$ExchUri="http://anonit.net/powershell",
- [Parameter(Mandatory=$true)][string]$Mailbox
- )
- $exchSession=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $exchUri -Authentication Kerberos
- # Import the session, redirect the import-session command output to null to remove the output from the import (exported commands, etc)
- Import-PSSession $exchSession | out-null
- $SMTPAddresses=get-recipient -identity $Mailbox| select emailaddresses -ExpandProperty emailaddresses
- # The output of this command places smtp: and SMTP: infront of the email addresses, use a double replace to remove smtp: and SMTP:
- $SMTPAddresses.replace("smtp:","").replace("SMTP:","")
- # close the session
- Remove-PSSession $exchSession
- # References https://community.spiceworks.com/scripts/show/3956-connect-to-exchange-powershell-remotely
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement