Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我输入这个命令...
Get-Package -ListAvailable -Filter newtonsoft
我得到了在其 ID 或描述/发行说明字段中引用字符串“newtonsoft”的所有包的列表。有没有办法只搜索 Id 字段?
您可以使用Where-Objectcmdlet 过滤结果。表示管道中的$_当前对象:
Where-Object
$_
Get-Package -ListAvailable -Filter newtonsoft | Where {$_.<prop-name> -match '<regex>'}
请注意,-match运算符将指定属性名称的值与指定的正则表达式匹配。具体来说,我认为你想要这个:
-match
Get-Package -ListAvailable -Filter newtonsoft | Where {$_.Id -match 'newtonsoft'}