In Powershell, How to print only the command syntax when no parameters are provided? Example:
PS> .\sign.ps1
sign.ps1 [-Trace] [-New] [-All] [[-File] <string[]>] [<CommonParameters>]
Instead I get the complete Help page for the command... Here's what I'm doing.
# sign.ps1
<#
.SYNOPSIS
Script for Signing Powershell Scripts
.PARAMETER New
Create a new code signing certificate for signing powershell scripts.
(requires Powershell to be run in admin mode in order to make the certificate)
.PARAMETER File
List of Powershell scripts to sign
.PARAMETER All
Sign all ps1 files in the current directory
.EXAMPLE
# Creates a new certificate stored in current directory as sign.pfx
PS> sign -New
# Sign all ps1 files in current directory
PS> sign -File *.ps1
#>
param(
[switch]$Trace,
[switch]$New,
[switch]$All,
[string[]]$File
)
if ($PSBoundParameters.Count -eq 0) {
Get-Help $MyInvocation.MyCommand.Path
exit 1
}