gpt4 book ai didi

powershell - PowerShell "Search"动词是干什么用的?

转载 作者:行者123 更新时间:2023-12-03 23:54:46 25 4
gpt4 key购买 nike

MSDN 页面“Approved Verbs for Windows PowerShell Commands”说:

The Find verb is used to look for an object. The Search verb is used to create a reference to a resource in a container.



“在容器中创建对资源的引用”是什么意思?这是否意味着为现有资源定义一个新名称?这是否意味着获取有关资源的一些信息并将该信息转换为引用?还是有别的意思?

如何使用“搜索”动词的示例是什么?这个 Action 与搜索有什么关系?

最佳答案

tl;博士

  • Search 之间的区别和 Find定义不明确在 PowerShell 领域。
  • 现有的、源自 Microsoft 的模块反射(reflect)了这种混淆 ,任意附带Find-*Search-* cmdlet,但不能同时使用两者。
  • 要解决此问题,请向 Microsoft 寻求说明 ,这可能导致:
  • Search 之间的有用区别和 Find这需要解释,然后可以指导 future 的实现。
  • 或将一个动词声明为另一个动词的(遗留)同义词,并建议以后只使用一个动词。


  • 正如 Approved Verbs for Windows PowerShell Commands 中所述,人类语言是模棱两可的,这总是与 PowerShell 对一致性的值得称赞的追求不一致。 .
    遗憾的是,该文档本身包含许多定义不明确的术语(截至撰写本文时),它们模糊地互换使用,例如资源、对象、项目、目标和引用。
    具有讽刺意味的是,该文件告诫:

    To enforce consistency across cmdlets, do not use a synonym of an approved verb.


    可以说,在英语中查找和搜索 ARE 同义词 ,只有确定结果的确定程度才能区分它们: 搜索比查找 更开放: 你可以搜索没有结果,但找到意味着一个成功的结果。
    在命名 cmdlet 时,这种区分是否值得?
    可以说不是 ,这反射(reflect)在现实世界的 Microsoft 实现中 - 例如 Active Directory、Exchange 和 PowerShellGet 模块 - 选择一个术语而排除另一个术语。
    同样具有讽刺意味的是,该文档似乎颠倒了 find 和 search 之间的人类语言关系:
  • Find

  • Looks for an object in a container that is unknown, implied, optional, or specified.


  • Search

  • Creates a reference to a resource in a container.


    撇开对象与容器的歧义(以及在此上下文中的引用是什么)不谈,它是 Find这里的定义听起来比 Search 更开放。 - 反对人类语言(英语)。

    felixfbecker关于 Search-* 的名词部分,请注意以下几点和 Find-*小命令:

    I think another difference is that the noun in Search-Noun describes what is searched [the search space] while the noun in Find-Noun describes what is being searched for [the kind of item]. Therefore, e.g., a cmdlet Search-Wikipedia makes sense, whereas Find-Wikipedia does not. Find-WikipediaArticle and Search-Wikipedia-Article, on the other hand, both make sense, but mean different things.

    关于powershell - PowerShell "Search"动词是干什么用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39173396/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com