What is the difference between dot (.) and ampersand (&) in PowerShell?

后端 未结 4 943
天涯浪人
天涯浪人 2021-02-12 22:05

In PowerShell, what is the difference between using dot (.) and ampersand (&) when invoking a cmdlet, function, script file, or operable program?

4条回答
  •  天涯浪人
    2021-02-12 22:58

    Like Mathias mentioned as a comment in this thread. & is used to invoke the expression whatever comes after the & and . is used to invoke it in the current scope and is normally used to dot source a helper file which contains functions to make it available in callers scope.

    • See https://mcpmag.com/articles/2017/02/02/exploring-dot-sourcing-in-powershell.aspx for more dot sourcing.

提交回复
热议问题