I have a function that returns the value of a global variable. When I assign this result to a local variable, and changing the local value the another variable is changing too.
Example:
function setGlobal
{
$temp = @{}
$temp.id = 50;
$Global:global1 = $temp;
return $Global:global1;
}
then I call this function, and set the result value:
$result = setGlobal
$result.id = 80
now both variables has the same value.
$Global:global1 # id = 60
$result # id = 60
How can I prevent this from happening? And why does changing the local value will affect the global copy?