Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Variable and deepcopy

Reply
 
Old 04-21-2008   #1 (permalink)


XP
 
 

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.

My System SpecsSystem Spec
Old 05-15-2008   #2 (permalink)


XP
 
 

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.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
$Variable Is In {1,2,3,4} PowerShell
Import-CSV from Web/Variable PowerShell
Set-Variable PowerShell
tab and variable PowerShell
How can I ensure that a variable is a built-in powershell variable? PowerShell


Vista Forums 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 Ltd

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