| pid | 1026 |
|---|---|
| author | Paul Brice |
| title | User Obj ProxyAddresses |
| date | 2009-04-14 15:03:39 -0700 |
| format | posh |
| parent | 0 |
A code sample to gather all assigned proxy addresses of an Active Directory User Object.
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