Skip to content

Instantly share code, notes, and snippets.

@ciscoo
Created February 26, 2017 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciscoo/d2ddc7f035f93be6ddc51e350850533b to your computer and use it in GitHub Desktop.
Save ciscoo/d2ddc7f035f93be6ddc51e350850533b to your computer and use it in GitHub Desktop.
#requires -version 4.0
$Username = Get-ChildItem Env:EW_USERNAME
$Password = Get-ChildItem Env:EW_PASSWORD
$Server = "ftp.eagleweather.com/public_html/assets/img/autoUpdateImages"
$CapturesPath = "C:\Program Files (x86)\InterWARN\Captures"
$Client = New-Object System.Net.WebClient
$Client.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
# We only care for pictures.
Get-ChildItem $CapturesPath -Filter *.jpg |
ForEach-Object {
try {
$uri = New-Object System.Uri("$Server\$_.Name")
$Client.UploadFile($uri, $_.FullName)
}
catch {
$_.Exception.Message | Out-File errors.txt -Append
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment