我的脚本将目录(和所有子目录)复制到以今天的日期命名的新目录到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
1 回答
您的第一个错误是因为默认情况下禁用 remote to remote symbolic links .
您可以通过运行以下命令来检查(使用提升的命令提示符):
然后将返回您的状态:
并使用以下方法更改此行为
并再次查询以查看新状态:
你的第二个错误就像它说的那样:
您的目标路径(
\MyServerName\C$\Backup\Folder\Folder\...\file.txt
)超出了错误消息中的限制 .