-3

Hoping someone can help.

I have in a text file 100's of lines that copy and pastes files.

Copy-Item "Source\File123.txt" -Destination "Destination\Folder123"
Copy-Item "Source\File542.txt" -Destination "Destination\Folder542"
Copy-Item "Source\File567.txt" -Destination "Destination\Folder567"

How can I get powershell to execute each of these lines by loading the text file.

Thanks

Manu
  • 1,685
  • 11
  • 27

1 Answers1

0
get-content C:\scripts\garbage.txt | % {Invoke-Command $([ScriptBlock]::Create("$_"))}

...But this raises the question.. how did you end up with a txt file with the commands actually in it..? Would be much easier if the file just had source & destination in them.

Pink
  • 48
  • 11