如果没有共享文件夹,Windows计算机文件复制将不起作用

问题描述:

我正在使用VSTS版本管理。第一步是做一个“Windows机器文件复制”。设置如下。执行robocopy时出现“访问被拒绝”的错误消息时失败。以下设置中显示的文件路径被转换为\\ machine \ e $ \ xxxx \ TargetFolder。我为什么拒绝访问?如果我在目标文件夹上创建共享文件夹并将目标文件夹更改为:\\ machine \ TargetFolder,则不会收到此消息。 Admin用户是本机上的本地管理员。如果没有共享文件夹,Windows计算机文件复制将不起作用

我的问题是为什么我需要设置共享文件夹才能使其工作。为什么不能用它的管理共享(即\\机\ E $ \ XXXX \ TargetFolder)

enter image description here

这里是日志。源服务器和目标服务器都是Win 2012R2服务器。 UAC在目标服务器上关闭。我试过/ B和/ ZB作为参数,并没有奏效。

2017-02-20T12:21:10.4545267Z Downloading artifact 
2017-02-20T12:21:11.4375965Z Cleaning artifacts directory: C:\VSTS_agent\ReleaseManagementVSTS\r1\a 
2017-02-20T12:21:11.6306012Z Cleaned artifacts directory: C:\VSTS_agent\ReleaseManagementVSTS\r1\a 
2017-02-20T12:21:11.6396014Z Starting artifacts download... 
2017-02-20T12:21:11.6426015Z Downloading linked artifact Release Build of type Build... 
2017-02-20T12:21:11.6486018Z Ensuring artifact folder C:\VSTS_agent\ReleaseManagementVSTS\r1\a\Release Build exists and is clean. 
2017-02-20T12:21:11.6856039Z Preparing to get the list of available artifacts from build 
2017-02-20T12:21:12.0926382Z Preparing to download artifact: release 
2017-02-20T12:21:12.1066374Z Artifact Type: ServerDrop 
2017-02-20T12:21:12.5536635Z Caching items under 'release' in the file container... 
2017-02-20T12:21:12.7186787Z Caching complete. (165 ms) 
2017-02-20T12:21:17.8480056Z Download complete. 
2017-02-20T12:21:17.8500047Z 51 placed file(s): 51 downloaded, 0 empty 
2017-02-20T12:21:17.8500047Z 11 MB downloaded at 2188 KB/sec. Download time: 00:00:05.0976254. Parallel download limit: 4. 
2017-02-20T12:21:17.8510054Z Downloaded linked artifact Release Build 
2017-02-20T12:21:17.8510054Z Finished artifacts download 
2017-02-20T12:21:17.8610039Z ##[section]Finishing: Download Artifacts 
2017-02-20T12:21:17.8690051Z ##[section]Starting: Copy files from $(System.DefaultWorkingDirectory)/Release Build/release 
2017-02-20T12:21:17.9680113Z ============================================================================== 
2017-02-20T12:21:17.9680113Z Task   : Windows Machine File Copy 
2017-02-20T12:21:17.9680113Z Description : Copy files to remote machine(s) 
2017-02-20T12:21:17.9690126Z Version  : 1.0.39 
2017-02-20T12:21:17.9690126Z Author  : Microsoft Corporation 
2017-02-20T12:21:17.9690126Z Help   : [More Information](https://go.microsoft.com/fwlink/?linkid=627415) 
2017-02-20T12:21:17.9690126Z ============================================================================== 
2017-02-20T12:21:18.0380182Z Preparing task execution handler. 
2017-02-20T12:21:19.8101219Z Executing the powershell script: C:\VSTS_agent\ReleaseManagementVSTS\_tasks\WindowsMachineFileCopy_xxxx\1.0.39\WindowsMachineFileCopy.ps1 
2017-02-20T12:21:24.0233892Z Copy started for - 'machine' 
2017-02-20T12:21:28.8116953Z 
2017-02-20T12:21:28.8116953Z ------------------------------------------------------------------------------- 
2017-02-20T12:21:28.8116953Z ROBOCOPY  ::  Robust File Copy for Windows        
2017-02-20T12:21:28.8116953Z ------------------------------------------------------------------------------- 
2017-02-20T12:21:28.8116953Z 
2017-02-20T12:21:28.8146952Z Started : Monday, February 20, 2017 7:21:28 AM 
2017-02-20T12:21:28.8156949Z 2017/02/20 07:21:28 ERROR 5 (0x00000005) Getting File System Type of Destination \\machine\E$\xxx\TargetFolder\ 
2017-02-20T12:21:28.8156949Z Access is denied. 
2017-02-20T12:21:28.8156949Z 
2017-02-20T12:21:28.8156949Z 
2017-02-20T12:21:28.8156949Z Source : C:\VSTS_agent\ReleaseManagementVSTS\r1\a\Release Build\release\ 
2017-02-20T12:21:28.8167052Z  Dest - \\machine\E$\xxx\TargetFolder\ 
2017-02-20T12:21:28.8167052Z 
2017-02-20T12:21:28.8167052Z  Files : *.* 
2017-02-20T12:21:28.8167052Z   
2017-02-20T12:21:28.8167052Z Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30 
2017-02-20T12:21:28.8167052Z 
2017-02-20T12:21:28.8167052Z ------------------------------------------------------------------------------ 
2017-02-20T12:21:28.8186939Z 
2017-02-20T12:21:28.8196951Z 2017/02/20 07:21:28 ERROR 5 (0x00000005) Creating Destination Directory \\machine\E$\xxx\TargetFolder\ 
2017-02-20T12:21:28.8196951Z Access is denied. 
2017-02-20T12:21:28.8196951Z 
2017-02-20T12:21:28.8977003Z \\machine was deleted successfully. 
2017-02-20T12:21:28.8977003Z 
2017-02-20T12:21:28.9177039Z ##[error]System.Management.Automation.RuntimeException: Copying failed for resource : machine 
2017-02-20T12:21:28.9177039Z Copying failed. Consult the robocopy logs for more details. ---> System.Management.Automation.RuntimeException: Copying failed for resource : machine 
2017-02-20T12:21:28.9177039Z Copying failed. Consult the robocopy logs for more details. 
2017-02-20T12:21:28.9177039Z --- End of inner exception stack trace --- 
2017-02-20T12:21:28.9177039Z at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) 
2017-02-20T12:21:28.9177039Z at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) 
2017-02-20T12:21:28.9177039Z at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) 
2017-02-20T12:21:28.9177039Z at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) 
2017-02-20T12:21:28.9177039Z at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) 
2017-02-20T12:21:28.9187021Z at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args) 
2017-02-20T12:21:28.9407042Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1. 
2017-02-20T12:21:28.9427038Z ##[section]Finishing: Copy files from $(System.DefaultWorkingDirectory)/Release Build/release 
2017-02-20T12:21:28.9507042Z ##[section]Finishing: Release 
+0

如果使用Windows计算机文件复制任务/步骤,则不需要设置共享文件夹。什么是详细构建日志?你可以在这里分享吗? –

+0

日志已添加到帖子中。 –

+0

尝试使用该用户登录该机器并在E中创建一个新文件夹,然后使用它。另一方面,尝试指定另一个管理员帐户并检查结果。 –

此问题已通过使用Active Directory帐户解决。这解决了无法使用管理员共享的Robocopy的问题。这适用于AD用户有权访问的计算机,以及AD无法访问但本地管理员Windows帐户的设置与AD帐户名称相同的计算机。