Author Posts

September 27, 2017 at 8:39 am

I run a powershell script to copy a directory with all subdirectories to a directory with today's date of name to 10 server and get the two errors below! how can i fix it ?

 $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 $source -Destination $location -recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : WriteError: (tmp:DirectoryInfo) [Copy-Item],   IOException
+ FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 ch
aracters, and the directory name must be less than 248 characters.
At C:\Users\baa065sa\Powershell skript\Untitled1.ps1:9 char:1
+ Copy-Item $source -Destination $location -recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo          : WriteError: (se.cambio.cosmi...-ejb   server.jar:FileInfo) [Copy-Item], PathTooLongExcepti
on
+ FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand