I need to setup a scheduled task that is going to download files from an ftp location (or just run it manually)
I have the following for a ps1
$File = "c:\store\somefilename.zip" $ftp = "ftp://username:password@example.com/pub/outbound/somefilename.zip""ftp url: $ftp" $webclient = New-Object System.Net.WebClient $uri = New-Object System.Uri($ftp) "Downloading $File..." $webclient.DownloadFile($uri, $File)
I'm guessing I can set $File to *.* but I don't want to download the same files everytime. I am hoping the users will be moving the files once downloaded but who can quarentee that. What for loop can I add to achieve this?
I found the following but not sure how I would alter my original to add this in.
foreach($listOut in $listIn)
{
$a = ((Get-Date) - [datetime]::ParseExact($listOut.ModifiedDate, "MMM dd HH:mm", $null)).days
if ($a -le 0)
{
Get-FTPItem -path $dirBank\$($listOut.Name) -LocalPath d:\backup\test\$($listOut.Name)
}
}Thanks in advance for the help.