We help IT Professionals succeed at work.
Get Started

AWS & PoweShell - How do I go through a text file from within a script

FikreDeneke
FikreDeneke asked
on
171 Views
Last Modified: 2018-02-14
How can I run Script 2 by it's self? Script 1 is a cmd file, but what do I need to delclare in Script 2 to make it a valid script?

Script 1 pulls out all the snapshots (their ID) for a volume to a text file (snaps.txt)
aws ec2 describe-snapshots --filters Name=volume-id,Values=vol-123456 --query Snapshots[*].{ID:SnapshotId} --output text >c:\temp\snaps.txt

Script 2 should go through the text file snaps.txt and tag all the snapshots.
for /F %i in (c:\temp\snaps.txt) do aws ec2 create-tags --resources %i --tags Key=Environment,Value=ABC123


I ran the file snapscript01.cmd to create the list of snapshots in a text file which worked. Awesome. What type of file do I need to run through that output file snaps.txt so it can loop it? I created a cmd and bat with just the command text and it didn't work. No error. I don't want to touch the existing backup script. I want a new script.
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE