自动完成用户输入的PowerShell 2.0 [英] Auto Complete User Input PowerShell 2.0

查看:420
本文介绍了自动完成用户输入的PowerShell 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有数据(超过1000个不同的值)的大名单,我希望用户能够从从PowerShell控制台列表中选择特定的值。

I have a large list of data (over 1000 different values) and I want the user to be able to select certain values from the list from a PowerShell console.

什么是从控制台中的最简单的方法,以允许用户快速选择值?

What is the easiest way from within the console to allow the user to quickly select values?

我要像做tab完成,或使用箭头键的值,以滚动的功能,但我不知道该怎么办任这些事情。

I would like to do something like tab completion or the ability to use the arrow keys to scroll through the values but I am not sure how to do either of these things.

任何意见将是极大的AP preciated。

Any advice would be greatly appreciated.

推荐答案

标签的PowerShell完成可以扩展到自定义的参数和参数值(V3)。然而,这是高级功能的属性。您可以使用 ValidateSetAttribute 来做到这一点。

PowerShell tab completion can be extended to custom parameters and parameter values (in v3). However, this is a property of advanced functions. You can use the ValidateSetAttribute to do that.

检查高级功能在TechNet帮助主题:<一href=\"http://technet.microsoft.com/en-us/library/hh847806.aspx\">http://technet.microsoft.com/en-us/library/hh847806.aspx

Check the Technet help topic on advanced functions: http://technet.microsoft.com/en-us/library/hh847806.aspx

您可以替换PowerShell中的tabexpansion(V2)和tabexpansion2(V3)函数来自动完成参数值的高级功能之外。您可以通过运行得到这个在PowerShell中V3基本定义

You can replace the tabexpansion (v2) and tabexpansion2 (v3) function in PowerShell to auto complete parameter values outside of advanced functions. You can get a basic definition of this in PowerShell v3 by running

 Get-Content function:TabExpansion2

下面是显示自定义选项卡扩展功能的一个例子。

Here is an example of showing custom tab expansion function.

<一个href=\"http://www.powershellmagazine.com/2012/11/29/using-custom-argument-completers-in-powershell-3-0/\">http://www.powershellmagazine.com/2012/11/29/using-custom-argument-completers-in-powershell-3-0/

不过,如果你想给用户能够自动完成值的读主机类型的输入,你需要编写<$ C代理$ C>读主机来实现这一目标。

But, if you want to the user to be able to auto complete values for a Read-Host kind of input, you need to write a proxy for Read-Host to achieve that.

您可以任选,看PowerTab模块在 HTTP://powertab.$c$cplex.com/

You can, optionally, look at PowerTab module at http://powertab.codeplex.com/

这篇关于自动完成用户输入的PowerShell 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆