I don’t used Powershell a lot before. But lately I’m starting to discover more and more of it’s richness and how it can make my life a lot simpler.
One of the things that took me some time to figure was how to include other scripts inside your own Powershell script. Now doing is this is very easy(once you know it).
One way to use functions from another script is to use the dot sourcing operator to run the script so that the functions from the script are part of the calling scope. To dot source the script, you use the dot source operator (a period) followed by the path to the script containing the functions you wish to include in your current scope. After you do this, you can call the functions from the other script directly.
An example:
PS C:\> . C:\scripts\ConversionFunctions.ps1
PS C:\> convertToMiles 6
6 kilometers equals 3.7266 miles