Basic script not returning coeerct info

by Beefstew at 2013-02-15 07:05:10

Hi,

Could anyone tell me why this most basic scipt is only returning the "name" value and not the "proxyaddresses"?

Thanks
$strFilter = "(objectCategory=User)"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"

$colProplist = "name", "proxyAddresses"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{$objItem = $objResult.Properties; $objItem.name}
by ArtB0514 at 2013-02-15 07:36:04
Wouldn’t it be easier to use the AD cmdlets from RSAT?
$Proxy = Get-ADUser -Filter * -Properties proxyAddresses | Select Name,proxyAddresses

or the equivalent in the Quest snap-in?
$Proxy = Get-QADUser -SizeLimit 0 -IncludedProperties proxyAddresses | Select Name,proxyAddresses
by Beefstew at 2013-02-15 08:13:53
How would I filter on a particlar OU please?

Cheers
by Klaas at 2013-02-15 08:31:45
$Proxy = Get-ADUser -SearchBase 'OU=yourOU,DC=yourcompany,DC=com' -Filter * -Properties proxyAddresses | Select Name,proxyAddresses