Hello Community!
I am new to powershell and i have been playing around with getting files to upload using FTP.
I have got it working and i am happy with the results but i would like to get the script to exit if the upload fails and to only move the file if its successful.
#Files to Send $Dir="C:\test\Output" #ftp server $ftp = "ftp://xxx.xxx.xxx.xxx/" $user = "User" $pass = "Password" $webclient = New-Object System.Net.WebClient $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) foreach($item in (dir $Dir "*.csv")){ "Uploading $item..." $uri = New-Object System.Uri($ftp+$item.Name) $webclient.UploadFile($uri, $item.FullName) Move-Item c:\test\Output\*.csv c:\test\Output\copied
can anyone assist please?
Many Thanks in advance :-)
Kallum