Search code examples
linuxwindowspowershellsftpwindows-server

Transfer file from Windows to Linux without using 3rd party software and using Shell.Application only


How to transfer file from Window Server to Linux without using 3rd party software? I just can use pure PowerShell script to transfer zip file.

I'm using PowerShell v2.0 (I know it's pretty old and I don't have privilege to update to current version - only can use for Shell.Application script)

  1. Telnet successfully
  2. Destination server installed private/public key (which I gen from my server using PuTTYgen - but no privilege to install PuTTY or WinSCP)
$timestamp = (Get-Date).AddMonths(-1).ToString('yyyy-MM-dd')
$todaysDate = (Get-Date).AddDays(-1)
$source = "D:\Testing\*.csv", "D:\Testing\*.csv"
$target = "D:\Testing\bin\$timestamp.zip"
$housekeepZipFile = "D:\Testing\bin\*.zip"
$locationToTransfer = "D:\Testing\bin\*.zip"
$mftFileTransfer = "[email protected]:/UserName/Outbox"

Get-ChildItem -Path $locationToTransfer –Recurse | Where-Object {
    $_.LastWriteTime -gt (Get-Date).AddDays(-1)
} | Copy-Item -Destination $mftFileTransfer -Force

Is my syntax correct? Just now tried, seems not receive any file.

Using Window Server 2008


Solution

  • As Ansgar already commented, keys are used with SSH/SFTP. There's no support for SSH/SFTP in PowerShell nor in Windows 2008. If you need to use SSH/SFTP, you have to use 3rd party software/library.

    And as already said above, you do not need install privileges to use WinSCP nor PuTTY/psftp.