Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums

Go Back   Vista Forums > Vista technology newsgroups > PowerShell

Variable and deepcopy

Reply
 
Thread Tools Display Modes
Old 04-21-2008   #1 (permalink)
Newbie
BatchMan is on a distinguished road
 
Join Date: Mar 2008
XP
Posts: 2

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.
BatchMan is offline   Reply With Quote

Old 05-15-2008   #2 (permalink)
Newbie
BatchMan is on a distinguished road
 
Join Date: Mar 2008
XP
Posts: 2

Re: Variable and deepcopy

For informations.

About attribute (US) :
http://www.manning.com/payette/wpia_errata.pdf

About attribute (French)
ftp://ftp-developpez.com/laurent-dardenne/articles/Windows/PowerShell/VariablesContraintes/fichiers/Les-variables-contraintes-sous-PowerShell.pdf

"Deepcopy" :

gv V|Export-Clixml Variable-V.xml
$V2=Import-Clixml Variable-V.xml
$V2.name= "V2"
$v|gm
$V2|gm

Attention :
The type of V is Int32 and the type of V2 is PsVariable.
BatchMan is offline   Reply With Quote
 
Reply

Thread Tools
Display Modes









Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48