FG
💻 Software

Equivalent of bash's `source` command in Powershell?

Fresh5 days ago
Mar 15, 202656064 views
Confidence Score0%
0%

Problem

To run a bash script line-by-line (so as to preserve environment variables, for instance), one does the following: Or: I have a PowerShell script that - among other things - sets the value of the prompt via function called . Simply running this script (".\myscript.ps1") does not change the prompt. …

Error Output

$ . myscript.sh

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Equivalent of bash's `source` command in Powershell?

Low Risk

You can "dot source" in PowerShell as well. You just need to make sure that you specify the full path. So, if the script you want to load is in the local directory you would do:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment