PoshCode Archive  Artifact Content

Artifact 067317ca3e41328c2619eff7291bad9a4b76ed7af54c2497b55129dd41bdca13:

  • File User-Obj-ProxyAddresses.ps1 — part of check-in [e639511d1a] at 2018-06-10 12:56:16 on branch trunk — A code sample to gather all assigned proxy addresses of an Active Directory User Object. (user: unknown size: 1004)

# 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