I am trying to do a foreach loop to pull down a file from AWS. When I run Invoke-WebRequest -Uri $S3InstallerLoc -OutFile $S3OutFileoutside of a foreach loop on the server itself it pulls my test file down. When I stick it inside a foreach loop it does not pull down the file. When I attempt to do this from another server I am getting the following error: Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
Here is the entirety of the script:
$Servers = "AWS-GPOTEST"
$S3InstallerLoc = "https://s3-us-west-2.amazonaws.com/bucketname/test.txt"
$S3OutFile = "C:\Windows\Temp\Test.txt"
ForEach ($Server in $Servers)
{
Invoke-WebRequest -Uri $S3InstallerLoc -OutFile $S3OutFile
}