How to read a line from a file in PowerShell

前端 未结 2 1146
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 20:30

I am novice to the PowerShell scripting. I am looking to fulfill one of my requirement.

I have one hosts file which is having multiple host names and IP addresses. B

2条回答
  •  粉色の甜心
    2020-12-16 21:25

    I'm never seen anything from PowerShell, but I mean it can be helpful for you. Something like the following:

    foreach ($line in $lines.Split('\r\n')){
        Test-Connection  $line.Split(' ')[1]
    }
    

    http://en.wikipedia.org/wiki/Newline

提交回复
热议问题