PoshCode Archive  Artifact [5046d900ec]

Artifact 5046d900ecf9c18725b40d52eeb85b86d65388cfeeb05411bb4eac948ca7dc17:

  • File Get-ProxyAddress.ps1 — part of check-in [734f826d5f] at 2018-06-10 14:12:37 on branch trunk — This script enables you too search AD for SMTP addresses that are possibly in use, using the QUEST PowerShell PSSnapIn and searching the “proxyAddress” attribute of objects. The output details either that the SMTP address is not found in AD or you get details of the object that owns the SMTP address. (user: Paul Brice size: 1667)

# encoding: ascii
# api: powershell
# title: Get-ProxyAddress
# description: This script enables you too search AD for SMTP addresses that are possibly in use, using the QUEST PowerShell PSSnapIn and searching the “proxyAddress” attribute of objects. The output details either that the SMTP address is not found in AD or you get details of the object that owns the SMTP address.
# version: 0.1
# type: function
# author: Paul Brice
# license: CC0
# function: Get-ProxyAddresses
# x-poshcode-id: 6305
# x-archived: 2016-04-22T18:46:26
# x-published: 2016-04-15T07:45:00
#
# Save the code as: Get-ProxyAddress.ps1
# Usage: PS C:\> Get-ProxyAddress address@domain.com
#
Param (
    [Parameter(Mandatory=$true,
        Position=0,
        ValueFromPipeline=$true,
        HelpMessage="Enter SMTP address to search for in Active-Directory."
    )]
    [string]$objSMTP
	)
Function Get-ProxyAddresses ([string]$Address){
$objAD = $null
$objAD = Get-QADObject -LdapFilter "(proxyAddresses=*$Address*)" -IncludeAllProperties -SizeLimit 0 -ErrorAction SilentlyContinue
Write-Output $objAD
}#Close Function
#Validate Quest PSSnapin is loaded
Add-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
#Run Function to search AD for SMTP address
$Results = $null
$Results = Get-ProxyAddresses -Address $objSMTP | Select-Object Name,DisplayName,ObjectClass,Email,AccountisDisabled,AccountisLockedOut,MailNickName,LegacyExchangeDN -ErrorAction SilentlyContinue
IF($Results -eq $null){
Write-Host ""
Write-Host "No Object Found with .attribute[proxyAddress] containing $objSMTP."}
Else{$Results | Format-List *}
#End