Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You can save a PowerShell function to a script file with the `.ps1` extension. Here's how you can do it:
- 1. Open a text editor such as Notepad and paste the function code into it.
- 2. Save the file with a `.ps1` extension, for example `Add-Numbers.ps1`.
- 3. To use the function, you need to **dot-source** the script file in your PowerShell session. This means that you need to run the script file in the current scope so that the function is added to your session.
- To dot-source a script file, use the `.` operator followed by the path to the script file like this: `. C:\Path\To\Add-Numbers.ps1`. After dot-sourcing the script file, you can use the `Add-Numbers` function in your session.
- Make sure that your execution policy allows running scripts. You can check your execution policy by running `Get-ExecutionPolicy` and set it by running `Set-ExecutionPolicy`.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement