Powershell: Get-Command -Syntax should work with aliases

Created on 19 Jan 2018  路  5Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Get-Command -Syntax del

Expected behavior

del [-Path] <string[]> [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Recurse] [-Force] [-Crede
ntial <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <string[]>] [<CommonParameters>]                   

del -LiteralPath <string[]> [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Recurse] [-Force] [-
Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <string[]>] [<CommonParameters>]  

Actual behavior

Remove-Item
Area-Cmdlets-Core Hacktoberfest Issue-Enhancement Resolution-Fixed

All 5 comments

I just came here to log this. The existing behavior is most unhelpful.

One thought I have that differs from the above however is in the case of Get-Command -Syntax $someAliasName, I was thinking I'd prefer it show the actual alias mapping, followed by the syntax for the alias, especially since aliases shouldn't be used in scripts. The thinking behind this is that 100% of the time when I would use gcm del -syntax (or any alias in place of del), I'd be using the alias to save typing, as a shorthand to get the actual syntax for the command that will be invoked, and less as a command I actually want to invoke. So my expected behavior would look more like this:

del -> Remove-Item

del [-Path] <string[]> [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Recurse] [-Force] [-Crede
ntial <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <string[]>] [<CommonParameters>]                   

del -LiteralPath <string[]> [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Recurse] [-Force] [-
Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <string[]>] [<CommonParameters>]  

Or maybe the output should actually state "NOTE: del is an alias for the Remove-Item command", at the top or bottom of the output.

@SteveL-MSFT potentially a solid hackathon/up-for-grabs issue?

@TylerLeonhardt A great Hacktoberfest issue.

Sounds like an interesting challenge so I'll give it a shot

This can be closed @iSazonov / @ChrisLGardner :-)

Was this page helpful?
0 / 5 - 0 ratings