简体   繁体   中英

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 = "UserName@192.168.0.50:/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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM