2017-09-27 606 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尖叫的文件! –

相關問題