0
我想创建一个连接到网络驱动器的Powershell脚本,然后将远程文件与本地文件进行比较。如果远程目标(共享驱动器上)的文件较新,则将其复制到本地目标。Powershell脚本将远程路径中的文件与本地路径进行比较,并将其复制到本地路径(如果新增)
下面是我使用的代码。
net use Y:
if ($LastExitCode -ne 0)
{
net use Y: Path
}
$folders = @{local = 'Local Path';remote='Remote Path'},
$folders | Foreach {xcopy $_.remote $_.local /S /C /Y /D /I}
我得到以下输出
Local Name Y:
Remote Name \\Path of the shared drive
Resource Type Disk
The command Completed Sucessfully
File Not Found
Invalid Number of Parameters