Setting a global PowerShell variable from a function where the global variable name is a variable passed to the function

前端 未结 7 1282
北荒
北荒 2020-12-04 16:17

I need to set a global variable from a function and am not quite sure how to do it.

# Set variables
$global:var1
$global:var2
$global:var3

function foo ($a,         


        
相关标签:
7条回答
  • 2020-12-04 17:00

    As simple as:

    $A="1"
    function changeA2 () { $global:A="0"}
    changeA2
    $A
    
    0 讨论(0)
提交回复
热议问题