I am trying to use a variable that loops through a list of words to be used in downloading password-protected files from a URL.
sites.txt:
BOS
HFD
LGA
NYC
PHI
WWD
Powershell Script:
$sites = Get-Content C:\Users\...\sites.txt
$time = (Get-Date).ToString("yyyyMMdd")
$Username = 'hello'
$Password = 'world'
$url = "http://my.website/" + $sites + "/some.csv"
$Path = "D:\...\...\" + $sites + "/some.csv"
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.Networkcredential($Username, $Password)
$WebClient.DownloadFile( $url, $path )
I am getting "unexpected token" errors so, I'm assuming that I am not using the $site variable correctly in the URL string.