Pages

Monday, June 15, 2009

Reading XML file in PowerShell

Today, I am going to talk about reading an XML file in PowerShell.

Let’s define the XML structure file:


Declare a variable to get the content of XML file. Make sure the file path. In my case file is located in H:\ Drive and also my powerShell Home directory is H:\. I would always recommend you to use Full Path of the file.

PS H:\> $EmpList = get-content Employee_details.xml

And use the path to display the XML content information in tabular format.

PS H:\> $EmpList.Employee.Row


Dept_ID Dept Dept_Mgr
------- ---- --------
1 Admin Krishna
2 Finance Kadiyala
3 HR Vijaya
4 Consulting Vijaya Kadiyala

No comments: