While creating some custom Powershell commandlets using C# we were wondering how we could load these using a relative path.
Starting from Powershell 3.0 this became easy thanks to the introduction of the $PSScriptRoot variable. This variable always points to the folder the current script is located in.
An example:
Import-Module $PSScriptRoot\..\BuildScripts\CopyFile.dll