Iterating objects in XML file and writing to a text file

by Jan 10, 2013

HI All,

I'm using the following script to try to get some output from an XML file concerning certain objects.  I use the following:

[xml]$file = (Gc C:usersmedoc.xml)

foreach ($object in $Config.Configuration.objects.object) {write-output $object.alias, $object.PhysicalName, $object.ObjectType $object.role | out-string >> C:scriptsAllObjects.txt}

Using this code the information is outputted to the text file like this

name

Hammer

Tool

Helper

However, I need it to display the values horizontally in the text file.

If I use Write-host instead of write-output then the console shows the values formatted correctly in wide format (multiple columns instead of one) for each object.

How can I get the text file to also display the values horizontally for each object?

Thanks,

Mark