Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Export XML filename to CSV

$
0
0

Hello everyone,

i appreciate your help. I need advice about how to export to CSV XML filename. I have folder where are stored XML files and i am selecting special values to export to CSV. When i select $_.Name i get #document variable.

                         

Get-ChildItem -Path $OutputPath -Filter  '*.xml' |



  ForEach-Object {
      ([Xml](Get-Content -Path $_.Fullname -OutVariable Name ))   |

      select @{ L = 'Class';      E = { $_.Header.MessageInfo.Class } },
            @{ L = 'MessageID';   E = { $_.Header.MessageInfo.MessageID } },
            @{ L = 'Name'; E = { $_.Name } } },

Output looks like this 

Class               : MAIN_DOCUMENT

MessageID       : 0101010-10101-01bhf-5464

Name              : #document      

I want put the filename.xml to "name" variable. Thanks



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>