# encoding: ascii
# api: powershell
# title: User Obj ProxyAddresses
# description: A code sample to gather all assigned proxy addresses of an Active Directory User Object.
# version: 0.1
# type: function
# license: CC0
# function: Get-Proxy
# x-poshcode-id: 1026
# x-archived: 2009-09-15T18:52:47
#
#
Function Get-Proxy()
{
Process
{
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = "(cn=$_)"
$objSearcher.SearchScope = "Subtree"
$objUser = $objSearcher.FindOne()
[String]$DN = $objUser.properties.distinguishedname
$UserObj = [ADSI]"LDAP://$DN"
[String]$displayname = $UserObj.displayname
[String]$exchalias = $UserObj.mailnickname
[Array]$exchproxy = $UserObj.proxyaddresses
$displayname
$exchalias
ForEach($proxy In $exchproxy)
{
$proxy
}
}
}
[String]$UserCN = "bricep"
$UserCN | Get-Proxy