I've been noticing some behaviour in PowerShell that I wasn't expecting. If I want to create a copy of an array, and change the values in the copy, the values of the original get update as well. Why is this? For example:
[array]$myVar1 = @("OldText");
$myVar2 = $myVar1;
$myVar2[0] = "newText"
Write-Output "MyVar1: $myVar1"
Write-Output "MyVar2: $myVar2"
I was expecting MyVar1 to be "OldText" and MyVar2 to be "NewText." But they are now both "NewText"