This code has also been uploaded to Github Gist. ::Show("Files have been uploaded to $servername.") $date = $((Get-Date).ToString('yyyyMMdd')) Write-Host -ForegroundColor White "Do not close this window!" Write-Host -ForegroundColor Cyan "`r`nUploading files to $servername." $sessionOptions.AddRawSettings("FSProtocol", "2") $sessionOptions.AddRawSettings("TcpNoDelay", "1") $sessionOptions.AddRawSettings("AuthGSSAPI", "1") SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" $sessionOptions = New-Object WinSCP.SessionOptions -Property = ::Sftp $servername = "FTP Server Descriptive Name" ::LoadWithPartialName('Microsoft.VisualBasic') The New-SSHSession command should also give you the -keyfile parameter. I use a module for SSH connections called posh-ssh. If my information is up to date, Powershell still does not do SSH natively. #Requires WinSCP to be installed on local machineĪdd-Type -Path "C:\path\to\WinSCPnet.dll" I have installed the OpenSSH in Windows settings screen. #Upload files to an SFTP server via PowerShell ps1 file and executing it via a batch file for simplicity.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |