lundi 15 août 2016

Get values from .txt in Powershell

I'm having some difficulties in taking values ​​from a .txt file following a standard in powershell.

My .txt file has this structure:

<arquivo>teste.exe</arquivo>   <caminhoArquivo>C:/teste</caminhoArquivo>
<arquivo>carro.zip</arquivo>   <caminhoArquivo>C:/sistema/res</caminhoArquivo>
<arquivo>logs.txt</arquivo>   <caminhoArquivo>C:/log</caminhoArquivo>
<arquivo>http://ift.tt/2bj0aAm;   <caminhoArquivo>C:/sistema/res</caminhoArquivo>
<arquivo>modelos.jpg</arquivo>   <caminhoArquivo>C:/sistema/modelos</caminhoArquivo>
<arquivo>binarios.zip</arquivo>   <caminhoArquivo>C:/nova pasta</caminhoArquivo>
<arquivo>config.lua</arquivo>   <caminhoArquivo>C:/server</caminhoArquivo>

I would like to get the value between < arquivo > and < / arquivo> Ex: "teste.exe", and the value it between < caminhoArquivo> and < / caminhoArquivo > Ex: "C:/teste" with a foreach for each line of the txt file, but I am unable to do this, already I tried regex but I did not have success. Could help a newbie in powershell with this problem?

Thanks ! :D

Aucun commentaire:

Enregistrer un commentaire