Reputation: 44305
I can load a module in powershell like that:
$ModuleName = $ScriptDir + "\functions.ps1"
. $ModuleName
But how to do this in one single line?
Upvotes: 1
Views: 1450
Reputation: 200233
You're dot-sourcing a PowerShell script (extension .ps1
), not importing a (script) module (extension .psm1
).
You can do it in a single line like this:
. "$ScriptDir\functions.ps1"
or like this:
. (Join-Path $ScriptDir 'functions.ps1')
Upvotes: 1
Reputation: 1275
You could write something like this:
Join-Path $ScriptDir "\functions.psm1" | Import-Module
So first safely combine the scriptdir and scriptname together and then use that for importing the module.
Upvotes: 0