![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | tee-object bug [xml]$a = "<hello>there</hello>" $a | tee-object -variable test gives Exception retrieving string: "Cannot find an overload for "XmlNode" and the argument count: "3"." ... anybody dare to suggest the cause of this bug. Maybe a side effect of the powershell adapter. and an assumption tee-object makes? -Karl |
My System Specs![]() |
| | #2 (permalink) |
| | Re: tee-object bug Shouldn't you add a reference to $test or I'm missing something? PS > $test="" PS > [xml]$a = "<hello>there</hello>" PS > $a | tee-object -variable [ref]test hello ----- there The help for tee-object: -variable <string> Assigns a reference to the input objects to the specified variable. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic Quote: > [xml]$a = "<hello>there</hello>" > $a | tee-object -variable test > gives > > Exception retrieving string: "Cannot find an overload for "XmlNode" > and the argument count: "3"." > > .. anybody dare to suggest the cause of this bug. Maybe a side effect > of the powershell adapter. and an assumption tee-object makes? > > -Karl > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: tee-object bug At first glance it would appear to me that Tee-Object is trying to copy the XmlDocument by creating a new XmlNode. However, that would be impossible as XmlNode is abstract. It would be more rational to try to create a new XmlDocument. After throwing the exception into my errordialog script I see that it is actually trying to dynamically invoke a method. A fast search in .NET Reflector found a static "XmlNode" method. Microsoft.PowerShell.ToStringCodeMethods.XmlNode(PSObject) as String within System.Management.Automation.dll There were no other overloads visible. Looking at the stack trace I see it being called by PSObject.ToString(String, IFormatProvider). $a.ToString($null, $null) will give the same error. It seems to be that PSObject.ToString(String, IFormatProvider) can not process correctly when it is overridden by the XmlNode code method. PSObject.ToString is being called by the Set-Variable cmdlet so I don't see any easy way around this bug. "Karl Prosser[MVP]" <karl@xxxxxx_o_w_e_r_s_h_e_l_l.com> wrote in message news:%23BmlLChQIHA.4584@xxxxxx Quote: > [xml]$a = "<hello>there</hello>" > $a | tee-object -variable test > > gives > > Exception retrieving string: "Cannot find an overload for "XmlNode" and > the argument count: "3"." > > .. anybody dare to suggest the cause of this bug. Maybe a side effect of > the powershell adapter. and an assumption tee-object makes? > > -Karl |
My System Specs![]() |
| | #4 (permalink) |
| | Re: tee-object bug The problem occurs when value is piped to sv or pass to sv by tee. # no problem rv test -ea 0 sv test ([Xml]"<hello>there</hello>") $test # problen when assigned by piped value rv test -ea 0 [Xml]"<hello>there</hello>" | sv test $test rv test -ea 0 [Xml]"<hello>there</hello>" | % {sv test ($_)} $test # problem because tee calls sv rv test -ea 0 tee -va test -input ([Xml]"<hello>there</hello>") $test rv test -ea 0 [Xml]"<hello>there</hello>" | tee -va test $test --- somebody |
My System Specs![]() |
| | #5 (permalink) |
| | Re: tee-object bug On Dec 19, 2:57 am, Shay Levi <n...@xxxxxx> wrote: Quote: > Shouldn't you add a reference to $test or I'm missing something? > > PS > $test="" > PS > [xml]$a = "<hello>there</hello>" > PS > $a | tee-object -variable [ref]test > > hello > ----- > there > > The help for tee-object: > > -variable <string> > Assigns a reference to the input objects to the specified variable. > > ----- > Shay Levi > $cript Fanatichttp://scriptolog.blogspot.com > Hebrew weblog:http://blogs.microsoft.co.il/blogs/scriptfanatic > > > Quote: > > [xml]$a = "<hello>there</hello>" > > $a | tee-object -variable test > > gives Quote: > > Exception retrieving string: "Cannot find an overload for "XmlNode" > > and the argument count: "3"." Quote: > > .. anybody dare to suggest the cause of this bug. Maybe a side effect > > of the powershell adapter. and an assumption tee-object makes? Quote: > > -Karl- Hide quoted text - > - Show quoted text - just an FYI: using [ref] in this way doesn't work - that particular parameter takes a string. I think the reason it appears to work is because tee-object is silently ignoring the invalid variable name. replacing [ref] with any other text in square brackets has the same effect. - Oisin / x0n |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Is it possible to use Object.Object notation in vbscript ? | VB Script | |||
| Inherit from usercontrol - Object not set to instance of an object | .NET General | |||
| datalist -- Object reference not set to an instance of an object. | .NET General | |||
| Testing object arrays using Compare-Object and -contains | PowerShell | |||
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | PowerShell | |||