![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Issue: getting/setting variable content using Get/Set-Content I was playing with getting/setting variable content using Get/Set-Content and variable provider and found this: $x = 'Hi' gc variable:\x Hi sc variable:\x -Value 'Hello' gc variable:\x Hello sc variable:\x -Value (gc variable:\x) gc variable:\x Get-Content : The member "PSPath" is already present. At line:1 char:3 + gc <<<< variable:\x What happens? -- Thanks, Roman |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Issue: getting/setting variable content using Get/Set-Content This is a bug. Here's what's happening. When an object is returned from get-content, we attach a note property called PSPath that records where the object came from. This allows you to see where you got the object from: PS (1) > get-date > foo.txt PS (2) > (get-content foo.txt)[0].PsPath C:\Temp\foo.txt PS (3) > (get-content foo.txt)[1] Saturday, September 23, 2006 2:01:55 AM However - if the object already has such a property, then an error occurs since, by default, we don't overwrite existing properties: PS (25) > $a = 1 | add-member -mem noteproperty PSPath foo -pass PS (26) > $a 1 PS (27) > get-content variable:\a Get-Content : The member "PSPath" is already present. At line:1 char:12 + get-content <<<< variable:\a We need to modify get-content to force an overwrite of the PSPath property if it already exists... -bruce -- Bruce Payette [MSFT] Windows PowerShell Technical Lead Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scr.../hubs/msh.mspx "Roman Kuzmin" <RomanKuzmin@discussions.microsoft.com> wrote in message news:4EF98086-3A76-47EB-9931-6106181A6255@microsoft.com... >I was playing with getting/setting variable content using Get/Set-Content >and > variable provider and found this: > > $x = 'Hi' > gc variable:\x > Hi > > sc variable:\x -Value 'Hello' > gc variable:\x > Hello > > sc variable:\x -Value (gc variable:\x) > gc variable:\x > Get-Content : The member "PSPath" is already present. > At line:1 char:3 > + gc <<<< variable:\x > > What happens? > > -- > Thanks, > Roman |
My System Specs![]() |
![]() |
| Thread Tools | |
| |