Confusion on - filter vs -property vs select-object

Hi
Can someone please help me explain the difference between -filter vs -property vs select-object?

Example:

Get-ADUser -filter * -properties EmailAddress -SearchBase ‘OU=Paris,OU-Fr,DC=woshub,DC=com’| select-object Name, EmailAddress

why are we using - filter and -properties here when we are selecting emailaddress to display?

I tried reading up on the documentation Get-ADUser (ActiveDirectory) | Microsoft Docs

But still confused. Any help will be appreciated! Thank you

‘Filter’ is used to determine which user accounts are retrieved by specifying some criteria. ‘filter *’ means all user accounts. When a user account is retrieved, only about 10 properties are retrieved by default. If you want additional properties retrieved you need to use the ‘-properties’ switch and specify the additional properties. Once all the accounts and properties are retrieved, the select-object tells powershell which properties you want to display. In your example, if you did not specify the emailaddress in the properties switch, it would not be displayed by the select statement. The name property is retrieved by default.
HTH
David

Ahh thank you, David! And if I use property *, I would get all properties of the object? I often thought select-object is actually selecting objects and not properties of the object but thats good to know.

Is there where-object the same as -filter attributes?

Yes -properties * will retrieve all properties.

1 Like

where-object can get the same results as -filter in that you are determining which objects to retrieve based on some criteria but using the -filter is more efficient.

Okay, thank you so much!