views:

19

answers:

1

hi,

suppose i have 2 powershell scripts, test1.ps1 and test2.ps1

#test1.ps1

$a="test1"

##################

#test2.ps1

echo $a

how to ref. $a in test2.ps1 from test1.ps1?

A: 

In Script 1:

Set-Variable -Name a -Value "test1" -Scope Global
xcud
thanks, the Global scope works. but i hope the scope can be restricted within the script. which means, after the script exited, the variables will be destroyed. i tried the Script scope, but it does not work.
davidshen84
When you're done you can remove it with: Clear-Variable a
xcud