Hello everybody
I've got a little understanding problem with the following script:
function do-something {
param($path)
$path
}
$Path = "D:\Temp"
Write-Host $Path
. do-something -path "C:\Temp"
Write-Host $Path
Because of dot sourcing this function (this is a short version, the original script really needs to be dot sourced) into the same script, the variable $path will be overridden by the passed parameter into the function. The result is the following:
D:\Temp
C:\Temp
C:\Temp
Is there a solution to keep the variable outside the function with the value "D:\Temp" without changing the variable name inside the function ?
Any help is welcome.
Many thanks and best wishes,
maragam