Created
May 13, 2019 22:48
-
-
Save brettmillerb/c0723796341e5519e9708de8501e76b9 to your computer and use it in GitHub Desktop.
Get-Syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Syntax { | |
[CmdletBinding()] | |
param ( | |
$Command, | |
[switch] | |
$Normalise | |
) | |
$check = Get-Command -Name $Command | |
$params = @{ | |
Name = if ($check.CommandType -eq 'Alias') { | |
Get-Command -Name $check.Definition | |
} | |
else { | |
$Command | |
} | |
Syntax = $true | |
} | |
if ($Normalise) { | |
Get-Command @params | |
} | |
else { | |
(Get-Command @params) -replace '(\s(?=\[)|\s(?=-))', "`r`n " | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment