用于从远程机器复制文件的 Windows 实用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5162436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows utility to copy file from a remote machine
提问by Invincible
I am looking for native windows utility or powershell cmdlet for doing this. (Not SSH server over Windows)
我正在寻找本机 Windows 实用程序或 powershell cmdlet 来执行此操作。(不是 Windows 上的 SSH 服务器)
I have two machines on the same network. I want to copy files from machine1 to machine2 by executing some command on machine 2. That means I need to specify credentials for machine1 while copying the file.
我在同一个网络上有两台机器。我想通过在机器 2 上执行一些命令来将文件从机器 1 复制到机器 2。这意味着我需要在复制文件时为机器 1 指定凭据。
I found the PsExec
tool, which only allows copy file from psexec command execution machine to remote machine and execute it automatically. But, I don't want such behavior.
我找到了这个PsExec
工具,它只允许从 psexec 命令执行机器复制文件到远程机器并自动执行它。但是,我不想要这样的行为。
What is the best way to get the file from Machine1 onto machine2?
将文件从 Machine1 获取到 machine2 的最佳方法是什么?
回答by Anonymous
Make a batch file that first authenticates against the remote box, and then copies the file.
制作一个批处理文件,首先针对远程框进行身份验证,然后复制该文件。
run on machine1
在机器 1 上运行
@echo off
net use \\machine2\admin$ /user:machine2\Admind2 /password:password
copy \\machine2\c$\data.file c:\
net use \\machine2\admin$ /delete
Instead of using "copy" I would also look into using the free robocopy.exe
utility instead.
除了使用“复制”之外,我还会考虑使用免费robocopy.exe
实用程序。
回答by ravikanth
PowerShell Copy-Item does not support credentials for filesystem provider yet. So, that is ruled out.
PowerShell Copy-Item 尚不支持文件系统提供程序的凭据。所以,排除了。
Edit 2018: Powershell since V5 supports remote connections. See the examples in the current documentation for Copy-Item
2018 年编辑:Powershell,因为 V5 支持远程连接。请参阅当前文档中Copy-Item的示例
Copy a file to a remote computer
将文件复制到远程计算机
$Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul"
Copy-Item "D:\Folder001\test.log" -Destination "C:\Folder001_Copy\" -ToSession $Session
In 2011, PSExec was probably the only option you had. Also, check RemoteExec. http://www.isdecisions.com/en/software/remoteexec/
2011 年,PSExec 可能是您唯一的选择。另外,检查 RemoteExec。http://www.isdecisions.com/en/software/remoteexec/
I have not tried it myself but it helps in copying files to/from a remote machine.
我自己没有尝试过,但它有助于将文件复制到/从远程机器复制。
回答by Sniggerfardimungus
Have you looked into the putty ssh client for doing scp and a windows-based ssh server? I cannot recommend a particular ssh server for the windows platform, though I'm sure there are plenty of openssh-based applications out there, but I highly recommend the process. It is one that you'll need to be familiar with in the long-term of a digital career, anyway.
您是否查看过用于执行 scp 的 putty ssh 客户端和基于 Windows 的 ssh 服务器?我不能为 windows 平台推荐特定的 ssh 服务器,尽管我确信那里有很多基于 openssh 的应用程序,但我强烈推荐这个过程。无论如何,从长远来看,这是您需要熟悉的数字职业。