Robo 使用 PowerShell 将文件从网络驱动器复制到远程目标



我正在尝试将文件从我的网络驱动器复制到网络上的所有计算机,但我遇到了一些问题。第一件事是我收到此警告:

-------------------------------------------------------------------------------
ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Tuesday, June 30, 2020 9:33:31 AM
2020/06/30 09:33:33 ERROR 67 (0x00000043) Getting File System Type of Source \108wg-fs-053 - 
Section Folders4 - SCM4 - Backups" UserProfileBackup.ps1 C$UsersPublicDesktop r:1 w:0
The network name cannot be found.
Source = \108wg-fs-053 - Section Folders4 - SCM4 - Backups" UserProfileBackup.ps1 
C$UsersPublicDesktop r:1 w:0
Dest -
Files : *.*
Options : *.* /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
ERROR : No Destination Directory Specified.
Simple Usage :: ROBOCOPY source destination /MIR
source :: Source Directory (drive:path or \serversharepath).
destination :: Destination Dir  (drive:path or \serversharepath).
/MIR :: Mirror a complete directory tree.
For more usage information run ROBOCOPY /?

****  /MIR can DELETE files as well as copy them !

这些是我使用的 2 个代码 这个旨在将启动脚本复制到网络上的计算机,该计算机将每个计算机连接到共享驱动器

robocopy "\108wg-fs-053 - Section Folders4 - SCMscriptsstartupscript.vbs" "\$cheesec$ProgramDataMicrosoftWindowsStart MenuProgramsStartup" /r:1 /w:0

这个旨在备份用户数据

robocopy "\108wg-fs-053 - Section Folders4 - SCM4 - BackupsUserProfileBackup.ps1" "\$cheeseC$UsersPublicDesktop" /r:1 /w:0

我的目标是让每个人都能够从网络驱动器中提取各自的文件,并且都给我相同的错误。有什么修复吗?

几个问题:

  1. 您已经给了 Robocopy 来源:<一个文件>
  2. 您尚未将输入分离到源:...所以它在源中看到,目标为空
  3. Robocopy喜欢单引号

在 powershell 中调用 Robocopy,只需将源 + 目标修改为文件夹,并使用单引号分隔参数。

下面的示例复制 1x 文件。将 $src_file 更改为">.",表示整个文件夹

$src = 'C:LocalPCFolderWithFile2SynccoolFile2Sync.csv'
$dest = '\10.1.1.xDestFolderFolderForSyncdFiles'
$dest_dir = (Split-Path $dest.Replace("""","'") -Parent)
$src_dir  = (Split-Path $src.Replace("""","'")  -Parent)
$src_file = (Split-Path $src.Replace("""","'")  -Leaf -Resolve)
robocopy.exe "$src_dir" "$dest_dir" "$src_file" /IS /IT /IM /TBD /MT:1 /R:5 /W:5 /V /NP /LOG+:'C:LocalPClog.txt'
#/R:5  — Retry 5 times (you can set various number, default is 1 million).
#/W:5  — Wait for a few seconds before retrying (you can also set another number, the default is 30 seconds).
#/TBD  — Wait for share names To Be Defined (retry error 67).
#/MT:1 — Do multi-threaded copies with n threads (default is 8).
#/IS :: Include Same files.
#/IT :: Include Tweaked files.    
#/IM :: Include Modified files (Includes same files with different times).
#/NP   — No Progress – can’t show percentage copied.
#/V    — Generates verbose output, displaying skipped files.

最新更新