Reputation: 111
I have a powershell file in which i have a variable named $CurrentReleaseNumber
:
$CurrentReleaseNumber="4.5"
What i want to do is edit the value of this variable inside another powershell file. This second powershell file will update the value of this variable and the new value should now reflect in first powershell file. So after execution of second powershell file the first powershell file should look like :
$CurrentReleaseNumber="4.7"
Upvotes: 0
Views: 1586
Reputation: 13176
You can try this, it is called dot-sourcing (assuming both files are in the same folder and you are using PS version 3 or higher) :
script1.ps1 :
$myVariable = "hey !"
script2.ps1 :
. "$PSScriptRoot\script1.ps1"
$myVariable
Output :
hey !
Upvotes: 1