I have created a function that reads a directory listing and then the files contents for CNC program names/numbers. Each file have multiple program numbers which i have separated by “,” and are passed on as a obj (see code below). I want to export this to XML to upload to a database having each of the program names in a seperate entry. Whats the best/easiest method to achieve this?
$obj = New-Object -TypeName PSObject
$obj | Add-Member -MemberType NoteProperty -Name FullFileName -Value $CNCProgFileName
$obj | Add-Member -MemberType NoteProperty -Name ProgramName -Value $ProgramName
Creating a custom object like you are doing is good. I suggest creating a property that is an array so you can associate the many things in the array to one object.
You can see your list of stuff with
Select-Objectwith-ExpandPropertylike so:$obj | select -expand ListOfStuff.