In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?
In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?
In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?
Re: In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?
Try this on the PowerShell command line:
```
. .\MyFunctions.ps1
A1
```
The dot operator is used for script include, aka "dot-sourcing" (or ["dot source notation"](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-5.1#using-dot-source-notation-with-scope))
```
. .\MyFunctions.ps1
A1
```
The dot operator is used for script include, aka "dot-sourcing" (or ["dot source notation"](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-5.1#using-dot-source-notation-with-scope))