Getting text content from Tree Item

Mar 18, 2014 at 7:31 PM

For the life of me, I am stuck. Must be something simple I am overlooking.

I cannot seem to get the text content from a SysTreeView32 Tree or TreeItem into a variable. How can I get the text? I see that the text in the TreeItem is in the Name property. But I cannot seem to get it.

Using UIAUtomationSpy, I see one of many TreeItems as follows:
Get-UiaWindow -Class '#32770' -Name 'myapp*' | `
Get-UiaTree -AutomationId '1475' -Class 'SysTreeView32' -Name 'Tree1' | `
Get-UiaTreeItem -Name 'my text here'
I've tried every method and property and cmdlet I could find, but no luck. What can I use to get that 'my text here' into a variable? Or, what am I overlooking?

Thanks for your help,
Mar 18, 2014 at 7:41 PM
I tried compmgmt.msc and hand-made Windows Forms app. In both cases the name of a tree node is just Name ($element.Current.Name). There is also the Read-UiaControlName cmdlet:
Get-UiaWindow -pn mmc -n *comp*manag* | Get-UiaTree | Get-UiaTreeItem -Name *event*viewer* | Read-UiaControlName
Mar 18, 2014 at 7:47 PM
Thanks for your quick reply.

My error. Works as described.