Listing 1: Get-Usage.ps1 Param([switch]$Verbose) function RemoveCommonParameters($string) { " [-Verbose]"," [-Debug]"," [-ErrorAction ]", ` " [-ErrorVariable ]", " [-OutVariable ]", ` " [-OutBuffer ]", " [-Confirm]", " [-WhatIf]" | ForEach-Object { $string = $string.Replace($_, [string]::Empty)} return $string } foreach($arg in $args) { $cmd = Get-Command $arg switch ($cmd.CommandType ) { Alias { # ------- BEGIN CALLOUT A ------- $usage = $cmd.ResolvedCommand.Definition $usage = $usage.Replace($cmd.ResolvedCommandName, $arg) # ------- END CALLOUT A ------- } # ------- BEGIN CALLOUT B ------- default { $usage = $cmd.Definition} # -------END CALLOUT B ------- } # ------- BEGIN CALLOUT C ------- if(!$Verbose){$usage = RemoveCommonParameters($usage)} # ------- END CALLOUT C ------- $usage }