I have a text file which a list of JSON files.
Using Powershell, I am able to extract these out of the file and then print the filenames out.
However I want to write a command then execute that in a foreach loop, but the concatenation is proving tricky.
This is my code so far:
foreach($line in [System.IO.File]::ReadLines("C:\Temp\DbAdmin\ImportDERReturn\ImportDERReturn.txt"))
{
Write-Host 'aws s3 rm s3://Derwent-storage-internal/staging/returns/' + $line.Substring(0,16) + ' --profile DER'
}
However im getting the following output:
aws s3 rm s3://Derwent-storage-internal/staging/returns/ + RET02022203.json + --profile DER
But what I want is the following:
aws s3 rm s3://Derwent-storage-internal/staging/returns/RET02022203.json --profile DER
How do I get this output? How do I get my Powershell script to execute this line?