Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Created May 13, 2019 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettmillerb/c0723796341e5519e9708de8501e76b9 to your computer and use it in GitHub Desktop.
Save brettmillerb/c0723796341e5519e9708de8501e76b9 to your computer and use it in GitHub Desktop.
Get-Syntax
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