2017-09-27 611 views
1

我的脚本将一个目录(和所有子目录)复制到一个以今天的日期命名的新目录中,以复制到10个不同的服务器。复制项错误:无法遵循符号链接,因为它的类型被禁用

$ServerList = Get-Content 'C:\Users\test\Powershellskript\testservrar.txt' 
ForEach ($Server in $ServerList) 
{ 
    $source = "\\$Server\C$\Java\testIX" 
    $distanation = "\\$Server\C$\Backup" 
    $today = (Get-Date).ToString('YY-MM-DD') 
    $location = New-Item -Path $distanation -Type Directory -Name $today 
    Copy-Item $source -Destination $location -recurse 
} 

但我得到了下面的两个错误,我该如何解决这个问题?

 
Copy-Item : The symbolic link cannot be followed because its type is disabled. 
At C:\Users\baa065sa\Powershell skript\Untitled1.ps1:9 char:1 
 
Copy-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. 
At C:\Users\baa065sa\Powershell skript\Untitled1.ps1:9 char:1 
+0

为什么?我怎样才能解释错误? –

+0

对不起,代码没有格式化,当我张贴,并没有提供任何解释,我删除了我以前的评论 – Manu

+0

它看起来像这里有一个解决方案:https://stackoverflow.com/questions/229643/how-doi-i-克服这个符号链接不能被遵循,因为它的类型是 –

回答

1

你的第一个错误是因为远程到远程符号链接默认情况下禁用。

可以通过运行检查这个(使用提升的命令提示符):

fsutil behavior query SymlinkEvaluation 

然后将返回自己的地位:

Local to local symbolic links are enabled. 
Local to remote symbolic links are enabled. 
Remote to local symbolic links are disabled. 
Remote to remote symbolic links are disabled. 

而且使用改变这种行为:

fsutil behavior set SymlinkEvaluation R2R:1 

然后再次查询以查看新状态:

> fsutil behavior query SymlinkEvaluation 

Local to local symbolic links are enabled. 
Local to remote symbolic links are enabled. 
Remote to local symbolic links are disabled. 
Remote to remote symbolic links are enabled. 

你的第二误差是完全一样的,它说:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters

你的目标路径(\MyServerName\C$\Backup\Folder\Folder\...\file.txt)超过在错误消息中的限制。

+0

第一个错误:我应该在计算机上运行fsutile行为设置SymlinkEvaluation R2R:1来备份吗?或者你运行脚本的机器? 其他错误:我知道有一些文件,他们有太长的名字,但如何备份没有powershell尖叫的文件! –

相关问题