PowerShell: Load a Script

By Xah Lee. Date: . Last updated: .

Run a script in its own scope

# run script with full path
~/temp/myscript.ps1

if scriptPath is a file name in current dir, you need to put ./ in front.

# run script in current dir

./myscript.ps1

Run a script in current session scope (Dot sourcing operator)

this loads the script into current session, meaning, all variable and function are importorted into the current session.

. scriptPath

. ./myscript.ps1

PowerShell. Profile and Script