PoshCode Archive  Artifact [67eae9794c]

Artifact 67eae9794cfa954e0dd02d12c6291aa28ae916157f1b096443bacc9e245d7b2a:

  • File Get-ProxyAddress.ps1 — part of check-in [32e7ad9190] at 2018-06-10 12:58:53 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: 1694)

# 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: 1594
# x-derived-from-id: 2517
# x-archived: 2016-03-05T06:02:00
# x-published: 2010-01-20T08:08: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