1

I am looking how to create a script that gets the first line of a text file then runs a command then gets the second line of the text file and runs a command again etc ...

Here is a piece of code I had done but it just fetch a line and run the command.

code

Thank you for your answers

1
  • 1
    Please do not add code as image. Instead edit your question and insert the code as formatted text. Commented Mar 26, 2021 at 10:29

1 Answer 1

2

You can do something like -

$file = Get-Content -Path "D:\test.txt"
foreach ($line in $file){
  //Run the command
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.