0

Is it possible to dot source a path with join-path?

Example

With MASTER.ps1 I invoke CHILD.ps1

MASTER Lives in C:\Folder

CHILD Lives in C:\Folder\Sub

MASTER.ps1
$FooBar = 'Cheese'
"C:\Folder\Sub\CHILD.ps1 " | Invoke-Expression


CHILD.PS1

. (Join-Path $PSScriptRoot\..\ 'MASTER.ps1')
Write-Output "$FooBar"


Things I tried
    . (Join-Path $PSScriptRoot\..\ 'MASTER.ps1')
    . (Join-Path $PSScriptRoot "\..\MASTER.ps1")
    . (Join-Path "$PSScriptRoot\..\MASTER.ps1")
    . (Join-Path "$PSScriptRoot\..\" 'MASTER.ps1')
phuclv
  • 37,963
  • 15
  • 156
  • 475
arealhobo
  • 447
  • 1
  • 6
  • 17
  • You might use: [`Invoke-Command -NoNewScope (Join-Path $PSScriptRoot\..\ 'MASTER.ps1')`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7) – iRon May 08 '20 at 05:14
  • `. (Join-Path $PSScriptRoot '..\master.ps1')` works perfectly fine for me – Mathias R. Jessen May 08 '20 at 09:55

0 Answers0