Basic script not returning coeerct info

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #6278

    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

You must be logged in to reply to this topic.