Greetings,
Last week I finally got the opportunity to use Powershell Studio. I have been given a huge AD management project and am having fun learning all the controls, methods and properties.
My question is - how can you check if an object “type” is suitable for the addrange method on a combobox?
One of my forms has two combo boxes. One is populated using an ad search.
I use the searcher object and the findall method piped into a select statement to create two properties called “display” and “value” (lets call the object $adresults).
This object is the parameter to the addrange method and the “display” is assigned to displaymember and “value” is assigned to valuemember of the combobox.
The values are displayed fine and the values are selected perfectly as expected.
The next combobox I am trying to populate from xml elements. I do a:
[xml]$config = get-content (c:\config.xml).
The path $config.accounttype.status has seven instances and each has two child elements called “display” and “value”. These two display as properties when I enter $config.accountype.status.
I use that path as the input to the addrange method and do the same for the displaymember and valuemember as I did for the AD object.
Problem here is that instead of displaying the values contained in the “display” property, the text that is displayed is the typename of the object (xmlelement).
I checked the addrange method help and it says it expects a system.object which seems like a a fairly generic superclass.
I did a getype() and gettype().basetype on both my $adresults and $config.accounttype.status objects and I get the same result!
The typename of the ad object is adsearcher and the typename of the xml object is xmlelement.
So my questions are as follows:
Why does the xml object result in a display of the typename and not the display property?
What command or help can I consult to determine if an object is suitable as input to a method? (In the interest of debugging this type of thing in the future)
As the addrange method does not appear to like my xml object, what’s the quickest way to convert this to a generic object? (im using a foreach and new-psobject and adding to array type stuff - just wondering if there’s anything quicker).
Thanks
David Z