A template for file transfers via SFTP
Requirements:
Posh-SSH
Powershell Version 3+
Parameters to pass:
sftpUpload.ps1
[-logFile ]
[-sourceFile ]
[-sftpServer ]
[-sftpDest ]
[-username ]
[-password ]
How to use:
.\sftpUpload.ps1 -logFile "C:\LogFile_$(Get-Date -UFormat %Y%m%d%H%M).txt" -sourceFile "C:\bla.txt" -sftpServer "server.bla.com" -sftpDest "/foo/bar" -username "username" -password (ConvertTo-SecureString "password" -AsPlainText -Force)
Notes:
Password is passed as secure string for security purposes. You can, but I don't recommend, change how the Param is set up.
I.E.
Param(
[string]$logFile,
[string]$sourceFile,
[string]$sftpServer,
[string]$sftpDest,
[string]$username,
[SecureString]$password
)
TO:
Param(
[string]$logFile,
[string]$sourceFile,
[string]$sftpServer,
[string]$sftpDest,
[string]$username,
[string]$password
)
After the above code block:
$password = ConvertTo-SecureString "$password" -AsPlainText -Force)
That way you can avoid converting the password to SecureString when passing the parameter to the script. Again I don't recommend doing this for security reasons
-
Notifications
You must be signed in to change notification settings - Fork 0
AjdinMasic-code/SFTP-Transfer
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A template for file transfers via SFTP
Resources
Stars
Watchers
Forks
Releases
No releases published