Scripting 如何引用另一个powershell脚本中的值?

Scripting 如何引用另一个powershell脚本中的值?,scripting,powershell-2.0,Scripting,Powershell 2.0,假设我有两个powershell脚本,test1.ps1和test2.ps1 #test1.ps1 $a=“test1” ################## #test2.ps1 回音$a 如何从test1.ps1引用test2.ps1中的$a?脚本1: Set-Variable -Name a -Value "test1" -Scope Global 谢谢,全球范围有效。但我希望可以在脚本中限制范围。这意味着,脚本退出后,变量将被销毁。我尝试了脚本作用域,但它不起作用。

假设我有两个powershell脚本,test1.ps1和test2.ps1

#test1.ps1

$a=“test1”

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

#test2.ps1

回音$a

如何从test1.ps1引用test2.ps1中的$a?

脚本1:

Set-Variable -Name a -Value "test1" -Scope Global

谢谢,全球范围有效。但我希望可以在脚本中限制范围。这意味着,脚本退出后,变量将被销毁。我尝试了脚本作用域,但它不起作用。