功能重音与显示命令

时间:2019-12-09 14:00:19

标签: powershell

以下是示例函数:

function Verb-Noun
{
    [CmdletBinding()]
    [Alias()]
    [OutputType([int])]
    Param
    (
        $Param1=""
    )
    DynamicParam {
        $ParameterName = 'Param2'
        $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
        $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute
        $ParameterAttribute.Mandatory = $true
        $AttributeCollection.Add($ParameterAttribute)
        $arrSet = @("eéééé","test")
        $ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($arrSet)
        $AttributeCollection.Add($ValidateSetAttribute)
        $RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParameterName, [string], $AttributeCollection)
        #End of dynamic parameters
        $RuntimeParameterDictionary.Add($ParameterName, $RuntimeParameter)
        return $RuntimeParameterDictionary
    }

    Begin
    {
    }
    Process
    {
    }
    End
    {
    }
}

使用这样的制表符补全时:

动词名词-param2 TAB->正确显示“eéééé”,

,但不带show-command。 所以我的意思是使用时:

显示命令动词名词

和true菜单中选择“eéééé”,然后单击“ RUN” 出现在命令行中

动词名词-Param2eΘΘΘΘ^ M

eΘΘΘΘ应该是eéééé。

到目前为止,我的研究是在具有不同编码的另一台PC上运行show-command,但这没有负面影响。对workaound或直接解决方案有什么想法,如何通过show-command使其起作用?

0 个答案:

没有答案