What is the point of the last command in this MSDN powershell Add-Member example? -
example 6 msdn article on add-member copying properties of 1 object another:
function copy-property ($from, $to) { foreach ($p in get-member -inputobject $from -membertype property) { add-member -inputobject $to -membertype noteproperty ` -name $p.name -value $from.$($p.name) -force $to.$($p.name) = $from.$($p.name) } }
just playing code, last line of $to.$($p.name) = $from.$($p.name)
seems totally redundant. description on page says last line gives new property same name original property. doesn't that, appears try set value of new property value of original property. done add-member call.
is bug in example? i'm guessing is, i'm still new powershell, , have found enough "quirks" great have confirmed.
Comments
Post a Comment