Include relative files in PowerShell

I would like to include script files with such pseudo syntax:

Include '.\scripA.ps1'

But the only thing I have found is some thing like this:

$thisScript = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
. ($thisScript + '.\scriptA.ps1')

that is ugly.

Is there some nice way to include scripts with relative paths?


You can utilize the $PSScriptRoot parameter like this:

. "$PSScriptRoot\script.ps1"

You can dot-source (include) the file:

. .\scriptA.ps1

To get the full path of the script:

Resolve-Path .\scriptA.ps1