Call variable in call stacks

58 views Asked by At

I came across some code and couldn't understand why PowerShell can pass the value not in the function. Hope someone could kindly help.

Here's the revised code structure:

  function ServerSetup () {

  param (
  [Parameter(Mandatory=$true)]
  [string] $Environment
)

 CreateFolder 
} 

function CreateFolder () {

$Environment = $Environment+"test2"
$Environment
}

My question is for $Environment parameter above, it’s not passed via the param (only $JsonObject), how come it still can get the value?

Thank you in advance.

0

There are 0 answers