View Single Post
Old 04-21-2008   #1 (permalink)
BatchMan
Newbie


  BatchMan is offline

Variable and deepcopy

Hello,
this code does not copy the fields Options and Attributes :
Code:
$SMA="System.Management.Automation"
$MyArray=@(2,4)
$Count=New-object "$SMA.ValidateCountAttribute" 1,3
(Get-Variable MyArray).Attributes.add($Count)
$Range=New-object "$SMA.ValidateRangeAttribute" 2,7
(Get-Variable MyArray).Attributes.add($Range)
(Get-Variable MyArray).Options=[System.Management.Automation.ScopedItemOptions]"Allscope"
 
Copy-Item -Path variable:MyArray -Destination variable:MyArray2
 
gv MyArray|fl *
gv MyArray2|fl *
How to make a deepcopy for one variable ?
Thanks.