目标 - 找到这样做的powershell方法:
alias | findstr /i ">some_string<"
示例:我想找到包括情况不敏感的字符串" web"的所有别名。
- 非偶然方法:
alias | findstr /i "web"
- PS惯用方式:
alias | where name -icont "web" # Or something similar?
,但这不起作用...
注意:我正在使用PSV5.1。
我在做什么错?
听起来像是您在寻找 definity (别名指向的命令(的别名,其中包含字符串web
。
您可以这样做:
Get-Alias -Definition *web*
如果是需要包含web
的别名,请改用-Name
参数:
Get-Alias -Name *web*
可能值得一提的是,命令alias
解析为Get-Alias
,因此它们在功能上相同。alias -def *web*
也将工作
Mathias的答案是正确的方法。但是,使用Where-Object
CMDLET的错误是您正在通过Name
属性进行过滤,而您却不会通过Definition
属性过滤:
Get-Alias | Where Definition -Match "web"