Pwershell Get-Member vs -Properties * vs Overloading example: []::Method()

Pwershell Get-Member vs -Properties * vs Overloading example: ::Method()

I am barely Beginning to try powershell and I do not understand the three concepts above.

For example if one issues: get-aduser -filter {Name -like ‘aduser’} | gm
the results are all the members the of the object, which are very few in comparison with the results obtained from:
get-aduser -filter {Name -like ‘aduser’} -Proeprties *

So the question would be why Get-Member cannot show all the properties of the object?

In addition can anyone explain overloading? [system.Microsoft.whatever]::Method() vs having a $variable.Method() But I guess the second is instantiating the object.

And when one can use the get and set methods -> example System.String UserPrincipalName {get;set;} on an object? for example when i can use the get on get-aduser to get a certain property, or this can be only used if the the object is put inside a variable? or only pipe it trough select-object?
Thank you.

For the Get-ADUser part the reason Get-Member seems to show fewer attributes than adding the -Properties * is because the cmdlet does not load all the object properties by default. Adding the Properties parameter with the * is telling the cmdlet to load all the properties.

“So the question would be why Get-Member cannot show all the properties of the object?”

As Paul notes, Get-ADUser doesn’t load all of the properties by default. Its behavior is designed to reduce load on the domain controller. You can use -Properties to specify additional properties you want to query, or * to query all of them (for a performance hit).

“In addition can anyone explain overloading? [system.Microsoft.whatever]::Method() vs having a $variable.Method() But I guess the second is instantiating the object.”

Neither of these is overloading. The first is calling a static method of a class. The second, presuming $variable contains an instance of the class, is calling an instance method. The second does presume that the class has been instantiated.

“And when one can use the get and set methods → example System.String UserPrincipalName {get;set;} on an object? for example when i can use the get on get-aduser to get a certain property, or this can be only used if the the object is put inside a variable? or only pipe it trough select-object?”

You would generally not use the methods to manipulate the object - you would, in this example, use Set-ADUser. The Get/Set you’re seeing indicates that the property is readable (get) and writable (set), but the convention in PowerShell is to use cmdlets to perform those tasks.

get-aduser user -Properties * |gm

Typically when I use get-member I’m looking for methods only for which cmdlets don’t already exist.

The definitions are also included with the methods, basically instructions on how to use the method.

ex. I manage my itunes library through powershell. Using get-member of my libraryplaylist I find the search,addfile,playfirsttrack… methods and what arguments are required. I couldn’t possibly figure out what to do with just the properties output

Search Method IITTrackCollection Search (string, ITPlaylistSearchField)

$libraryplaylist.search($genre, $this.ITPlaylistSearchField.ITPlaylistSearchFieldgenre)

Thank you very much.