我在PowerShell 3中使用TabExpansion2,當我選項卡來完成一個參數時,它會調出我想要的字符串,但是用我不想要的語法包裝。格式化選項卡參數完成powershell
例如,當我打標籤-binName
後:
Use-Bin -binName @{Name=5.0}
我需要的是:
Use-Bin -binName 5.0
我使用這個腳本:https://www.powershellgallery.com/packages/PowerShellCookbook/1.3.6/Content/TabExpansion.ps1
這些調整選項:
$options["CustomArgumentCompleters"] = @{
"binName" = {Get-ChildItem -Path $global:TH_BinDir | Select-Object Name}
"dbName" = {Get-ChildItem -Path $global:TH_DBDir\RT5.7\ | Select-Object Name}
"patchSubDir" ={Get-ChildItem -Path $global:TH_BinDir\Patches\ | Select-Object Name}
"hmiSubDir" = {Get-ChildItem -Path $global:TH_HMIDir | Select-Object Name}
"moduleScript" = {Get-ChildItem -Path $global:TH_ModPaths | Select-Object Name}
"items" = {"bins", "databases", "modules"}
}
謝謝!
在[這個問題]底部的答案(http://stackoverflow.com/questions/30633098/powershell-param-validateset-values-with-spaces-and-tab-completion)有幫助嗎? – user4317867