Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param (
- $localPath = "C:\temp\ARK_Backup\",
- $remotePath = "/xxxx/ShooterGame/Saved/*"
- )
- try
- {
- # Load WinSCP .NET assembly
- Add-Type -Path "C:\temp\WinSCP\WinSCP-5.15.1-Automation\WinSCPnet.dll"
- # Setup session options
- $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
- Protocol = [WinSCP.Protocol]::Ftp
- HostName = "saves.4netplayers.de"
- UserName = "xx.xx.xx.xx"
- Password = "passwort"
- }
- $session = New-Object WinSCP.Session
- try
- {
- # Connect
- $session.Open($sessionOptions)
- # Format timestamp
- #$stamp = $(Get-Date -Format "yyyyMMddHHmmss")
- $stamp = $(Get-Date -Format "yyyyMMdd")
- # Donwload files
- $transferOptions = New-Object WinSCP.TransferOptions
- $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
- $session.add_QueryReceived( {
- Write-Host "Error: $($_.Message)"
- $_.Continue()
- } )
- #$transferResult = $session.GetFiles("/552919/ShooterGame/Saved/*", "D:\temp\ARK\*", $False, $transferOptions)
- $transferResult = $session.GetFiles($remotePath,($localPath + $stamp + "\*"), $False, $transferOptions)
- # Throw on any error
- $transferResult.Check()
- # Print results
- foreach ($transfer in $transferResult.Transfers)
- {
- Write-Host "Download of $($transfer.FileName) succeeded"
- }
- }
- finally
- {
- # Disconnect, clean up
- $session.Dispose()
- }
- exit 0
- }
- catch
- {
- Write-Host "Error: $($_.Exception.Message)"
- exit 1
- }
Add Comment
Please, Sign In to add comment