I am trying to create a full copy of an existing array. Every time I try to do this, it seems like it is not working. The fact is that I am changing the names of objects inside a new copied array, but they also change in the original array.
The code below is very simplified, as there is so much more to it than just renaming object names, but that proves what I think.
Code example:
Function Get-Fruits { Param ( $Fruits = @('Banana', 'Apple', 'Pear') ) foreach ($F in $Fruits) { [PSCustomObject]@{ Type = $F } } } $FruitsOriginal = Get-Fruits Function Rename-ObjectName {
The desired result is 2 completely separate arrays.
$ FruitsOriginal
Type ---- Banana Apple Pear
$ FruitsNew
Tasty fruits ------------ Banana Apple Pear
Thank you for your help.
source share