I am trying to create a script to set off a command to restart machines where the hostnames are located in a .txt file. I am running this on Jenkins so ideally this should be in Groovy, however a shell script would work.
I have tried to use Groovy to create this code. My aim is to locate the .txt file and apply this CMD command to it
String fileContent = new File("C:/Users/omr/Documents/Temp/test.txt").text
println fileContent
"cmd /c shutdown -r -t 0".execute(fileContent)
So far Ive not had any luck, I've researched a lot how to execute cmd commands from Groovy and they all state .execute(), however I don't feel this is right.