From 5393469c8a6dcaeacd6b710c74343f0255721bd8 Mon Sep 17 00:00:00 2001 From: Zachary Loeber Date: Sun, 12 Feb 2017 22:33:30 -0600 Subject: [PATCH] Replace the wrapper function with a proxy function for Out-Default to rectify the borking of PowerShell when the module is unloaded --- release/PSColor.psm1 | 80 +++++++-- release/PSColor.zip | Bin 7843 -> 5218 bytes release/PSColorHelper.ps1 | 347 -------------------------------------- src/PSColorHelper.ps1 | 347 -------------------------------------- 4 files changed, 64 insertions(+), 710 deletions(-) diff --git a/release/PSColor.psm1 b/release/PSColor.psm1 index daae7d0..18b6ddd 100644 --- a/release/PSColor.psm1 +++ b/release/PSColor.psm1 @@ -7,8 +7,6 @@ Add-Type -assemblyname System.ServiceProcess . "$PSScriptRoot\MatchInfo.ps1" . "$PSScriptRoot\ProcessInfo.ps1" - - $global:PSColor = @{ File = @{ Default = @{ Color = 'White' } @@ -34,28 +32,78 @@ $global:PSColor = @{ $script:showHeader=$true -New-CommandWrapper Out-Default -Process { +function Out-Default { + [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=113362', RemotingCapability='None')] + param( + [switch] + ${Transcript}, - if(($_ -is [System.IO.DirectoryInfo]) -or ($_ -is [System.IO.FileInfo])) + [Parameter(Position=0, ValueFromPipeline=$true)] + [psobject] + ${InputObject}) + + begin { - FileInfo $_ - $_ = $null + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) + { + $PSBoundParameters['OutBuffer'] = 1 + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Core\Out-Default', [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters } + + $steppablePipeline = $scriptCmd.GetSteppablePipeline() + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } } - elseif($_ -is [System.ServiceProcess.ServiceController]) + process { - ServiceController $_ - $_ = $null + try { + if(($_ -is [System.IO.DirectoryInfo]) -or ($_ -is [System.IO.FileInfo])) + { + FileInfo $_ + $_ = $null + } + + elseif($_ -is [System.ServiceProcess.ServiceController]) + { + ServiceController $_ + $_ = $null + } + + elseif($_ -is [Microsoft.Powershell.Commands.MatchInfo]) + { + MatchInfo $_ + $_ = $null + } + else { + $steppablePipeline.Process($_) + } + } catch { + throw + } } - elseif($_ -is [Microsoft.Powershell.Commands.MatchInfo]) + end { - MatchInfo $_ - $_ = $null + try { + write-host "" + $script:showHeader=$true + $steppablePipeline.End() + } catch { + throw + } } -} -end { - write-host "" - $script:showHeader=$true + <# + + .ForwardHelpTargetName Out-Default + .ForwardHelpCategory Function + + #> } -Export-ModuleMember \ No newline at end of file +Export-ModuleMember Out-Default \ No newline at end of file diff --git a/release/PSColor.zip b/release/PSColor.zip index 8a09723cfd5a73af63953f74aa4bf85cdad4c689..7c77b48b69e1051d2b44e798fca2c7b85816e6f5 100644 GIT binary patch literal 5218 zcmZ`-cQ{;I`<+B5dWn`O!61lk5QZTbEu)v{z0PRSMhVe7(R+yAJJBM_Ac-gm(R)jD zVvyjId%yc#x%c-w=Q-znp8dyKd+&4B`@U<#lrS(U0000kAf`@Pk^8%}Ha-Rb044wc zZe5Ma**aK4;Z_J9Cs)1(?Rmr$FNvT0l0T>*KHVm$A*)bDq3sA*3>%i3lF@p~(-Nl~ z{()W|ruB1I92EyMdB(Yx(v#A)7r0}JIqQfyD}%d3e6M+4&Z!e3^}uq4xjL$U_C~*iheUu;AzPYa$(VBw zsjL)YBEBb{?4aQT#tlf|PPyN_&1q6t@R8W_?;+qq(b*RgqeR1)_OuC|S{P4ut5@Z8 zbAy<*7IYETLc7!Sb3^vGjW?au#KHNflol)_lclfWdo^-<7#Q<5Giy)OP-}ByCqI0k z8oSk+s}$YrT}id4$*mtB=~XJJ4xNn~1*N^FV$WpVP)~Q$?Nhgy5&0(k?xVe7a%C}F zTb17AF{-067qaO_gHD4#8oN7q%icF$j`o$;jwIy`Har1tMSBfS5R!`A4z7{1C8U-5 zDHNpfodG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sb|8vnt>BUyp3Hh9l#W`_T|e*r8(?zZNZ(m+R75YWNlzjv_WL{s}d4!nUi)Mt#e z>i4KsDmR;OdDp#R*y*U5#LGDm zBkhX!NWJbKWhG$>K#>c#*?rSLrEJ3kpWPB~MxkcN`sN)=BKVk^-%vZ#g={E;?Q0nc z0n4lUKdd!0>OMW=+;q}*wz^H(Sh(sMR@?#VCHEm)+wy)YI=w^Hxm^cfYcwA4MQ6Q` zT-KPPofBCUsWybGLa0nr?lzb`f&j#imRHnkL628u({Cd3f9^tlrJz)FxU?; zh&q8A#<4u!y{Y;I&t2D>Z7aDBY94?14u-Hs<>Ti$3Zl96X>V0Ofe@#AJzcWmH-%lf zSR-N5a&SxcCA3yZbUydU8p_Zxcu@a)%=vn9e_elvo_{0%E$R6K<9}^||10 -function New-CommandWrapper { -param( - ## The name of the command to extend - [Parameter(Mandatory = $true)] - $Name, - - ## Script to invoke before the command begins - [ScriptBlock] $Begin, - - ## Script to invoke for each input element - [ScriptBlock] $Process, - - ## Script to invoke at the end of the command - [ScriptBlock] $End, - - ## Parameters to add, and their functionality. - ## - ## The Key of the hashtable can be either a simple parameter name, - ## or a more advanced parameter description. - ## - ## If you want to add additional parameter validation (such as a - ## parameter type,) then the key can itself be a hashtable with the keys - ## 'Name' and 'Attributes'. 'Attributes' is the text you would use when - ## defining this parameter as part of a function. - ## - ## The Value of each hashtable entry is a scriptblock to invoke - ## when this parameter is selected. To customize the pipeline, - ## assign a new scriptblock to the $newPipeline variable. Use the - ## special text, __ORIGINAL_COMMAND__, to represent the original - ## command. The $targetParameters variable represents a hashtable - ## containing the parameters that will be passed to the original - ## command. - [HashTable] $AddParameter -) - -Set-StrictMode -Version Latest - -## Store the target command we are wrapping, and its command type -$target = $Name -$commandType = "Cmdlet" - -## If a function already exists with this name (perhaps it's already been -## wrapped,) rename the other function and chain to its new name. -if(Test-Path function:\$Name) -{ - $target = "$Name" + "-" + [Guid]::NewGuid().ToString().Replace("-","") - Rename-Item function:\GLOBAL:$Name GLOBAL:$target - $commandType = "Function" -} - -## The template we use for generating a command proxy -$proxy = @' - -__CMDLET_BINDING_ATTRIBUTE__ -param( -__PARAMETERS__ -) -begin -{ - try { - __CUSTOM_BEGIN__ - - ## Access the REAL Foreach-Object command, so that command - ## wrappers do not interfere with this script - $foreachObject = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Foreach-Object") - - $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand( - '__COMMAND_NAME__', - [System.Management.Automation.CommandTypes]::__COMMAND_TYPE__) - - ## TargetParameters represents the hashtable of parameters that - ## we will pass along to the wrapped command - $targetParameters = @{} - $PSBoundParameters.GetEnumerator() | - & $foreachObject { - if($command.Parameters.ContainsKey($_.Key)) - { - $targetParameters.Add($_.Key, $_.Value) - } - } - - ## finalPipeline represents the pipeline we wil ultimately run - $newPipeline = { & $wrappedCmd @targetParameters } - $finalPipeline = $newPipeline.ToString() - - __CUSTOM_PARAMETER_PROCESSING__ - - $steppablePipeline = [ScriptBlock]::Create( - $finalPipeline).GetSteppablePipeline() - $steppablePipeline.Begin($PSCmdlet) - } catch { - throw - } -} - -process -{ - try { - __CUSTOM_PROCESS__ - $steppablePipeline.Process($_) - } catch { - throw - } -} - -end -{ - try { - __CUSTOM_END__ - $steppablePipeline.End() - } catch { - throw - } -} - -dynamicparam -{ - ## Access the REAL Get-Command, Foreach-Object, and Where-Object - ## commands, so that command wrappers do not interfere with this script - $getCommand = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Get-Command") - $foreachObject = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Foreach-Object") - $whereObject = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Where-Object") - - ## Find the parameters of the original command, and remove everything - ## else from the bound parameter list so we hide parameters the wrapped - ## command does not recognize. - $command = & $getCommand __COMMAND_NAME__ -Type __COMMAND_TYPE__ - $targetParameters = @{} - $PSBoundParameters.GetEnumerator() | - & $foreachObject { - if($command.Parameters.ContainsKey($_.Key)) - { - $targetParameters.Add($_.Key, $_.Value) - } - } - - ## Get the argumment list as it would be passed to the target command - $argList = @($targetParameters.GetEnumerator() | - Foreach-Object { "-$($_.Key)"; $_.Value }) - - ## Get the dynamic parameters of the wrapped command, based on the - ## arguments to this command - $command = $null - try - { - $command = & $getCommand __COMMAND_NAME__ -Type __COMMAND_TYPE__ ` - -ArgumentList $argList - } - catch - { - - } - - $dynamicParams = @($command.Parameters.GetEnumerator() | - & $whereObject { $_.Value.IsDynamic }) - - ## For each of the dynamic parameters, add them to the dynamic - ## parameters that we return. - if ($dynamicParams.Length -gt 0) - { - $paramDictionary = ` - New-Object Management.Automation.RuntimeDefinedParameterDictionary - foreach ($param in $dynamicParams) - { - $param = $param.Value - $arguments = $param.Name, $param.ParameterType, $param.Attributes - $newParameter = ` - New-Object Management.Automation.RuntimeDefinedParameter ` - $arguments - $paramDictionary.Add($param.Name, $newParameter) - } - return $paramDictionary - } -} - -<# - -.ForwardHelpTargetName __COMMAND_NAME__ -.ForwardHelpCategory __COMMAND_TYPE__ - -#> - -'@ - -## Get the information about the original command -$originalCommand = Get-Command $target -$metaData = New-Object System.Management.Automation.CommandMetaData ` - $originalCommand -$proxyCommandType = [System.Management.Automation.ProxyCommand] - -## Generate the cmdlet binding attribute, and replace information -## about the target -$proxy = $proxy.Replace("__CMDLET_BINDING_ATTRIBUTE__", - $proxyCommandType::GetCmdletBindingAttribute($metaData)) -$proxy = $proxy.Replace("__COMMAND_NAME__", $target) -$proxy = $proxy.Replace("__COMMAND_TYPE__", $commandType) - -## Stores new text we'll be putting in the param() block -$newParamBlockCode = "" - -## Stores new text we'll be putting in the begin block -## (mostly due to parameter processing) -$beginAdditions = "" - -## If the user wants to add a parameter -$currentParameter = $originalCommand.Parameters.Count -if($AddParameter) -{ - foreach($parameter in $AddParameter.Keys) - { - ## Get the code associated with this parameter - $parameterCode = $AddParameter[$parameter] - - ## If it's an advanced parameter declaration, the hashtable - ## holds the validation and / or type restrictions - if($parameter -is [Hashtable]) - { - ## Add their attributes and other information to - ## the variable holding the parameter block additions - if($currentParameter -gt 0) - { - $newParamBlockCode += "," - } - - $newParamBlockCode += "`n`n " + - $parameter.Attributes + "`n" + - ' $' + $parameter.Name - - $parameter = $parameter.Name - } - else - { - ## If this is a simple parameter name, add it to the list of - ## parameters. The proxy generation APIs will take care of - ## adding it to the param() block. - $newParameter = - New-Object System.Management.Automation.ParameterMetadata ` - $parameter - $metaData.Parameters.Add($parameter, $newParameter) - } - - $parameterCode = $parameterCode.ToString() - - ## Create the template code that invokes their parameter code if - ## the parameter is selected. - $templateCode = @" - - if(`$PSBoundParameters['$parameter']) - { - $parameterCode - - ## Replace the __ORIGINAL_COMMAND__ tag with the code - ## that represents the original command - `$alteredPipeline = `$newPipeline.ToString() - `$finalPipeline = `$alteredPipeline.Replace( - '__ORIGINAL_COMMAND__', `$finalPipeline) - } -"@ - - ## Add the template code to the list of changes we're making - ## to the begin() section. - $beginAdditions += $templateCode - $currentParameter++ - } -} - -## Generate the param() block -$parameters = $proxyCommandType::GetParamBlock($metaData) -if($newParamBlockCode) { $parameters += $newParamBlockCode } -$proxy = $proxy.Replace('__PARAMETERS__', $parameters) - -## Update the begin, process, and end sections -$proxy = $proxy.Replace('__CUSTOM_BEGIN__', $Begin) -$proxy = $proxy.Replace('__CUSTOM_PARAMETER_PROCESSING__', $beginAdditions) -$proxy = $proxy.Replace('__CUSTOM_PROCESS__', $Process) -$proxy = $proxy.Replace('__CUSTOM_END__', $End) - -## Save the function wrapper -Write-Verbose $proxy -Set-Content function:\GLOBAL:$NAME $proxy - -## If we were wrapping a cmdlet, hide it so that it doesn't conflict with -## Get-Help and Get-Command -if($commandType -eq "Cmdlet") -{ - $originalCommand.Visibility = "Private" -} -} - # Helper method for simulating ellipsis function CutString { diff --git a/src/PSColorHelper.ps1 b/src/PSColorHelper.ps1 index 313349f..44931d8 100644 --- a/src/PSColorHelper.ps1 +++ b/src/PSColorHelper.ps1 @@ -1,350 +1,3 @@ -############################################################################## -## -## New-CommandWrapper -## -## From Windows PowerShell Cookbook (O'Reilly) -## by Lee Holmes (http://www.leeholmes.com/guide) -## -############################################################################## - -<# - -.SYNOPSIS - -Adds parameters and functionality to existing cmdlets and functions. - -.EXAMPLE - -New-CommandWrapper Get-Process ` - -AddParameter @{ - SortBy = { - $newPipeline = { - __ORIGINAL_COMMAND__ | Sort-Object -Property $SortBy - } - } - } - -This example adds a 'SortBy' parameter to Get-Process. It accomplishes -this by adding a Sort-Object command to the pipeline. - -.EXAMPLE - -$parameterAttributes = @' - [Parameter(Mandatory = $true)] - [ValidateRange(50,75)] - [Int] -'@ - -New-CommandWrapper Clear-Host ` - -AddParameter @{ - @{ - Name = 'MyMandatoryInt'; - Attributes = $parameterAttributes - } = { - Write-Host $MyMandatoryInt - Read-Host "Press ENTER" - } - } - -This example adds a new mandatory 'MyMandatoryInt' parameter to -Clear-Host. This parameter is also validated to fall within the range -of 50 to 75. It doesn't alter the pipeline, but does display some -information on the screen before processing the original pipeline. - -#> -function New-CommandWrapper { -param( - ## The name of the command to extend - [Parameter(Mandatory = $true)] - $Name, - - ## Script to invoke before the command begins - [ScriptBlock] $Begin, - - ## Script to invoke for each input element - [ScriptBlock] $Process, - - ## Script to invoke at the end of the command - [ScriptBlock] $End, - - ## Parameters to add, and their functionality. - ## - ## The Key of the hashtable can be either a simple parameter name, - ## or a more advanced parameter description. - ## - ## If you want to add additional parameter validation (such as a - ## parameter type,) then the key can itself be a hashtable with the keys - ## 'Name' and 'Attributes'. 'Attributes' is the text you would use when - ## defining this parameter as part of a function. - ## - ## The Value of each hashtable entry is a scriptblock to invoke - ## when this parameter is selected. To customize the pipeline, - ## assign a new scriptblock to the $newPipeline variable. Use the - ## special text, __ORIGINAL_COMMAND__, to represent the original - ## command. The $targetParameters variable represents a hashtable - ## containing the parameters that will be passed to the original - ## command. - [HashTable] $AddParameter -) - -Set-StrictMode -Version Latest - -## Store the target command we are wrapping, and its command type -$target = $Name -$commandType = "Cmdlet" - -## If a function already exists with this name (perhaps it's already been -## wrapped,) rename the other function and chain to its new name. -if(Test-Path function:\$Name) -{ - $target = "$Name" + "-" + [Guid]::NewGuid().ToString().Replace("-","") - Rename-Item function:\GLOBAL:$Name GLOBAL:$target - $commandType = "Function" -} - -## The template we use for generating a command proxy -$proxy = @' - -__CMDLET_BINDING_ATTRIBUTE__ -param( -__PARAMETERS__ -) -begin -{ - try { - __CUSTOM_BEGIN__ - - ## Access the REAL Foreach-Object command, so that command - ## wrappers do not interfere with this script - $foreachObject = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Foreach-Object") - - $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand( - '__COMMAND_NAME__', - [System.Management.Automation.CommandTypes]::__COMMAND_TYPE__) - - ## TargetParameters represents the hashtable of parameters that - ## we will pass along to the wrapped command - $targetParameters = @{} - $PSBoundParameters.GetEnumerator() | - & $foreachObject { - if($command.Parameters.ContainsKey($_.Key)) - { - $targetParameters.Add($_.Key, $_.Value) - } - } - - ## finalPipeline represents the pipeline we wil ultimately run - $newPipeline = { & $wrappedCmd @targetParameters } - $finalPipeline = $newPipeline.ToString() - - __CUSTOM_PARAMETER_PROCESSING__ - - $steppablePipeline = [ScriptBlock]::Create( - $finalPipeline).GetSteppablePipeline() - $steppablePipeline.Begin($PSCmdlet) - } catch { - throw - } -} - -process -{ - try { - __CUSTOM_PROCESS__ - $steppablePipeline.Process($_) - } catch { - throw - } -} - -end -{ - try { - __CUSTOM_END__ - $steppablePipeline.End() - } catch { - throw - } -} - -dynamicparam -{ - ## Access the REAL Get-Command, Foreach-Object, and Where-Object - ## commands, so that command wrappers do not interfere with this script - $getCommand = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Get-Command") - $foreachObject = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Foreach-Object") - $whereObject = $executionContext.InvokeCommand.GetCmdlet( - "Microsoft.PowerShell.Core\Where-Object") - - ## Find the parameters of the original command, and remove everything - ## else from the bound parameter list so we hide parameters the wrapped - ## command does not recognize. - $command = & $getCommand __COMMAND_NAME__ -Type __COMMAND_TYPE__ - $targetParameters = @{} - $PSBoundParameters.GetEnumerator() | - & $foreachObject { - if($command.Parameters.ContainsKey($_.Key)) - { - $targetParameters.Add($_.Key, $_.Value) - } - } - - ## Get the argumment list as it would be passed to the target command - $argList = @($targetParameters.GetEnumerator() | - Foreach-Object { "-$($_.Key)"; $_.Value }) - - ## Get the dynamic parameters of the wrapped command, based on the - ## arguments to this command - $command = $null - try - { - $command = & $getCommand __COMMAND_NAME__ -Type __COMMAND_TYPE__ ` - -ArgumentList $argList - } - catch - { - - } - - $dynamicParams = @($command.Parameters.GetEnumerator() | - & $whereObject { $_.Value.IsDynamic }) - - ## For each of the dynamic parameters, add them to the dynamic - ## parameters that we return. - if ($dynamicParams.Length -gt 0) - { - $paramDictionary = ` - New-Object Management.Automation.RuntimeDefinedParameterDictionary - foreach ($param in $dynamicParams) - { - $param = $param.Value - $arguments = $param.Name, $param.ParameterType, $param.Attributes - $newParameter = ` - New-Object Management.Automation.RuntimeDefinedParameter ` - $arguments - $paramDictionary.Add($param.Name, $newParameter) - } - return $paramDictionary - } -} - -<# - -.ForwardHelpTargetName __COMMAND_NAME__ -.ForwardHelpCategory __COMMAND_TYPE__ - -#> - -'@ - -## Get the information about the original command -$originalCommand = Get-Command $target -$metaData = New-Object System.Management.Automation.CommandMetaData ` - $originalCommand -$proxyCommandType = [System.Management.Automation.ProxyCommand] - -## Generate the cmdlet binding attribute, and replace information -## about the target -$proxy = $proxy.Replace("__CMDLET_BINDING_ATTRIBUTE__", - $proxyCommandType::GetCmdletBindingAttribute($metaData)) -$proxy = $proxy.Replace("__COMMAND_NAME__", $target) -$proxy = $proxy.Replace("__COMMAND_TYPE__", $commandType) - -## Stores new text we'll be putting in the param() block -$newParamBlockCode = "" - -## Stores new text we'll be putting in the begin block -## (mostly due to parameter processing) -$beginAdditions = "" - -## If the user wants to add a parameter -$currentParameter = $originalCommand.Parameters.Count -if($AddParameter) -{ - foreach($parameter in $AddParameter.Keys) - { - ## Get the code associated with this parameter - $parameterCode = $AddParameter[$parameter] - - ## If it's an advanced parameter declaration, the hashtable - ## holds the validation and / or type restrictions - if($parameter -is [Hashtable]) - { - ## Add their attributes and other information to - ## the variable holding the parameter block additions - if($currentParameter -gt 0) - { - $newParamBlockCode += "," - } - - $newParamBlockCode += "`n`n " + - $parameter.Attributes + "`n" + - ' $' + $parameter.Name - - $parameter = $parameter.Name - } - else - { - ## If this is a simple parameter name, add it to the list of - ## parameters. The proxy generation APIs will take care of - ## adding it to the param() block. - $newParameter = - New-Object System.Management.Automation.ParameterMetadata ` - $parameter - $metaData.Parameters.Add($parameter, $newParameter) - } - - $parameterCode = $parameterCode.ToString() - - ## Create the template code that invokes their parameter code if - ## the parameter is selected. - $templateCode = @" - - if(`$PSBoundParameters['$parameter']) - { - $parameterCode - - ## Replace the __ORIGINAL_COMMAND__ tag with the code - ## that represents the original command - `$alteredPipeline = `$newPipeline.ToString() - `$finalPipeline = `$alteredPipeline.Replace( - '__ORIGINAL_COMMAND__', `$finalPipeline) - } -"@ - - ## Add the template code to the list of changes we're making - ## to the begin() section. - $beginAdditions += $templateCode - $currentParameter++ - } -} - -## Generate the param() block -$parameters = $proxyCommandType::GetParamBlock($metaData) -if($newParamBlockCode) { $parameters += $newParamBlockCode } -$proxy = $proxy.Replace('__PARAMETERS__', $parameters) - -## Update the begin, process, and end sections -$proxy = $proxy.Replace('__CUSTOM_BEGIN__', $Begin) -$proxy = $proxy.Replace('__CUSTOM_PARAMETER_PROCESSING__', $beginAdditions) -$proxy = $proxy.Replace('__CUSTOM_PROCESS__', $Process) -$proxy = $proxy.Replace('__CUSTOM_END__', $End) - -## Save the function wrapper -Write-Verbose $proxy -Set-Content function:\GLOBAL:$NAME $proxy - -## If we were wrapping a cmdlet, hide it so that it doesn't conflict with -## Get-Help and Get-Command -if($commandType -eq "Cmdlet") -{ - $originalCommand.Visibility = "Private" -} -} - # Helper method for simulating ellipsis function CutString {