Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Extract substring

$
0
0

I am trying to extract the country code from a list like below which is in a text file:

lab.local/2003Servers/US/server123
lab.local/Servers/AU/server1

$file= Get-Content .\list.txt
foreach ( $i in $file)
{
}
How can I get the second index of /. Once I get the second index of / I can extract two characters after it using substring?




Viewing all articles
Browse latest Browse all 21975

Trending Articles



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