Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need help in picking up a pattern from text file.

$
0
0

I have to extract a hostname from one of the xml file in my system, the content of the xml file is something like this,

PS D:\SiteScope\groups> Get-Content D:\SiteScope\high_availability\ha.config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<HighAvailabilityConfiguration>
        <smtpUser></smtpUser>
        <timeout>60</timeout>
    </mailSettings>
    <primary disabled="false" numberOfZipBackups="2" profileId="primary-ei0263vwin-1366566383848" secure="false">
        <host>ei0269vwin</host>
        <port>8080</port>
    </primary>
</HighAvailabilityConfiguration>

The highlighted part is what i am interested in. from that i need to strip off host text and get only ei0269vwin as the end result.

I tried to use select-string command in various ways but not able to get the end result..

Can someone help me on this.


Viewing all articles
Browse latest Browse all 6937

Trending Articles