user1462199
user1462199

Reputation:

Whats The Difference Between These Cmdlets?

In PowerShell 3 if you are searching for a command you could use both, both Get-Help Get-* and Get-Command Get-* work?

So whats the major difference ?

Upvotes: 2

Views: 1470

Answers (2)

latkin
latkin

Reputation: 16792

The way I think of it is - Get-Command returns the technical information about commands (DLL, implementing type, function body for functions, etc), Get-Help returns the user-friendly information about commands (detailed syntax, examples, explanation of parameters, etc).

And Get-Command returns a normal object, which behaves perfectly normally and predictably, whereas Get-Help returns a weird formatted help object which is really only intended for viewing in the console, not for processing in code.

Upvotes: 1

Shay Levy
Shay Levy

Reputation: 126742

Both commands share a lot of information in common but the main difference is that Get-Help outputs MAML objects (which are "text based", error prone and even can be out dated) while Get-Command gets you real objects (metadata), that you can further investigate.

For most help parts, Get-Help is displaying pre-made help, contained in XML files. For other parts, Get-Help "is using" Get-Command to generate the information, like the SYNTAX section.

Get-Command also gets you information that Get-Help doesn't, like the module of the command, , it's DLL path (in case of a compiled cmdlet), parameter sets, and so on.

One is not a replacement for the other, you use both under different circumstances.

Upvotes: 2

Related Questions