PoshCode Archive  Artifact [4ef9253308]

Artifact 4ef9253308e7a900f89c525a41a54cc67e2d5eb5e945f2965e89aa2cecc914a1:

  • File Object-ProxyAddress-Scan.ps1 — part of check-in [0e87c8a795] at 2018-06-10 12:58:52 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: 1675)

# encoding: ascii
# api: powershell
# title: Object ProxyAddress Scan
# 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: 1593
# x-archived: 2016-03-17T03:15:42
# x-published: 2010-01-20T08:07: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