PoshCode Archive  Artifact [01c0796ef8]

Artifact 01c0796ef8105df59f59ed7981293e92b70dc443b9882207c3f34d5bcf6e3ae0:

  • File Get-ProxyAddress.ps1 — part of check-in [abb7d602d9] at 2018-06-10 14:17:12 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: 6520
# x-archived: 2016-10-29T06:27:39
# x-published: 2016-09-15T00:38: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