Differences

This shows you the differences between the selected revisions of the page.

script_download_timestamped_filename 2016-02-04 script_download_timestamped_filename 2022-06-16 (current)
Line 1: Line 1:
-====== [[download_timestamped_filename]] Downloading file to timestamped-filename ======+====== Downloading file to timestamped-filename ======
-===== Using WinSCP .NET Assembly =====+===== [[library]] Using WinSCP .NET Assembly =====
Use [[library|WinSCP .NET assembly]] from your favorite language. Use relevant construct of your language or API of your runtime environment for the file name formatting. Use [[library|WinSCP .NET assembly]] from your favorite language. Use relevant construct of your language or API of your runtime environment for the file name formatting.
Line 24: Line 24:
        UserName = "user"         UserName = "user"
        Password = "mypassword"         Password = "mypassword"
-        SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"+        SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."
    }     }
Line 35: Line 35:
        # Format timestamp         # Format timestamp
-        $stamp = $(Get-Date -f "yyyyMMddHHmmss")+        $stamp = $(Get-Date -Format "yyyyMMddHHmmss")
        # Download the file and throw on any error         # Download the file and throw on any error
Line 50: Line 50:
    exit 0     exit 0
} }
-catch [Exception]+catch
{ {
-    Write-Host $_.Exception.Message+    Write-Host "Error: $($_.Exception.Message)"
    exit 1     exit 1
} }

Last modified: by martin