$_.altRecipient -ne $null NOT finding values

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of Jeff Taylor Jeff Taylor 3 weeks, 6 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #52633
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

    I have this one liner:

    Get-ADUser -Filter * -Credential $creds | Where-Object {$_.altRecipient -ne $null}

    ...to find all users in our org that may have a value. It's not even returning my test User for which I did enter a DN value.

    What is my error?

    thanks

    #52637
    Profile photo of Craig Duff
    Craig Duff
    Participant

    Get-aduser returns a subset of ad properties, to get other properties that aren't in that default set you can specify them with the -properties parameter.

    Alternatively, it would also be more efficient to use the -filter parameter rather than where-object.

    • This reply was modified 4 weeks ago by Profile photo of Craig Duff Craig Duff.
    #52643
    Profile photo of Craig Duff
    Craig Duff
    Participant
    Get-aduser -filter {altrecipient -like '*'}

    That should work, I think.

    • This reply was modified 4 weeks ago by Profile photo of Craig Duff Craig Duff.
    #52815
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

    Thanks Craig, that indeed did work for me. Appreciate the reply, but the odd thing is, even though it found my test User object that has a value for altRecipient, the select operation doesn't show the value. How can I reveal the actual value as well as find the User object that contains it?

    Get-aduser -filter {altRecipient -like '*'} -Credential $creds | select altRecipient
    
    altRecipient
    ------------
                
    • This reply was modified 3 weeks, 6 days ago by Profile photo of Jeff Taylor Jeff Taylor.
    #52834
    Profile photo of Dan Potter
    Dan Potter
    Participant

    The filter doesn't require the property however you must include it for it to display.

    Get-aduser -filter {altRecipient -like '*'} -Credential $creds -properties altrecipient

    #52908
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

    Thanks Dan -properties altrecipient solved it.

    Learning!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.