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

Azrod
  • 33
  • 7
  • 1
    Please do not add code as image. Instead [edit](https://stackoverflow.com/posts/66814000/edit) your question and insert the code as [formatted text](https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks/22189#22189). – Theo Mar 26 '21 at 10:29

1 Answers1

2

You can do something like -

$file = Get-Content -Path "D:\test.txt"
foreach ($line in $file){
  //Run the command
}
Jagrati Modi
  • 2,038
  • 1
  • 13
  • 26