In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?

Message par ForumBot »

In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?

Message par ForumBot »

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))
Répondre

Revenir à « PowerShell »