Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Regex pattern - get PC hostnames from txt file

$
0
0

Hello,

im trying to extract hostnames from log file, these hostnames are written in their UNC format

Log.txt example:
\\pc-xp1 random text.. 
.. random text ...   \\pc-xp2
... another random text ...

$logfile = gc .\log.txt
$extract = [regex]::matches($logfile,$pattern)

Can u help me with that pattern value?  Result should be just
pc-xp1
pc-xp2


Viewing all articles
Browse latest Browse all 2562

Latest Images

Trending Articles



Latest Images

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