Hi Experts,
I am reading a host file file using getcontes cmdlet.
$lines = Get-Content myfile.txt | Where {$_ -notmatch '^\s+$'}
foreach ($line in $lines) {
$fields = $line -split '\s+'
$ip = $fields[0]
for ($i = 1; $i -lt $fields.Length; $i++) {
$ESXHost = $fields[$i]But in actual host file comments will be there starting with "#"
How to avoid those blank lines and comments while reading the file? Any regular expression to just read the line starting with IP address "127.0.0.1"?