Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, This may be the easiest question you have ever heard..But I must ask this since I am new to Powershell..

I need powershell to ask for a user input and then based on the input it must read the contents of an xml file corresponding to that input.

If user input is 1 then it should read the corresponding data of 1 from an xml file that is already defined.Can someone please help me on this??
Posted
Comments
Rockstar_ 18-Jun-13 7:43am    
i didn't get the searching criteria, could you plz explain clearly.?
Vysakh Venugopal 18-Jun-13 8:42am    
Powershell will ask for a userinput.Based on that input it must read the contents of an xml file..If you feel not difficult to go here,you may get an idea on this question..
http://stackoverflow.com/questions/17168825/how-to-make-powershell-repsond-to-userinput

$a = [xml](get-content C:\temp\centers.xml)
$b = Read-Host "Enter Center"

if (($c=$a.detail.centre | where {$_.name -eq $b}) -ne $null)
{
Write-Host $c.name
Write-Host $c.servername
Write-Host $c.ip
Write-Host $c.uname
Write-Host $c.pwd
Write-Host $c.dbname
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900