locked
Copying files is not conistant on mapped drive. (Copy-Item : Could not find a part of the path) RRS feed

  • Question

  • While copying files from source to destination (destination is a mapped drive). Has 2 servers so done in loop, Sometime gives error. Here everything was copied to server 1 without any issue, but gave below error on server 2.

    VERBOSE: Performing operation "Copy File" on Target "Item: C:\Source\Project1\Views\Shared\_LogOnPartial.cshtml 
    Destination: N:\Views\Shared\_LogOnPartial.cshtml".
    Copy-Item : Could not find a part of the path 'N:\Views\Shared\_LogOnPartial.cshtml'.
    At C:\TeamCity\Checkout_Code\Utility\ForKetan\XcopyReleasetoSite.ps1:197 char:15
    +                     Copy-Item <<<<  -Path $releaseDirectory\* -Destination $InstallPath  -Force -Recurse  -Verbose 
    + CategoryInfo          : WriteError: (_LogOnPartial.cshtml:FileInfo) [Copy-Item], DirectoryNotFoundException
    + FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand

    Note: I am deteting files from Destination before copying.

    Tuesday, April 23, 2013 6:20 PM

Answers

  • Not sure if this is the issue, but perhaps try this:

       Copy-Item -Path $releaseDirectory -filter * -Destination $InstallPath  -Force -Recurse  –Verbose


    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    • Marked as answer by NewTo-Net Wednesday, April 24, 2013 1:19 AM
    Tuesday, April 23, 2013 10:27 PM

All replies

  • hard to tell from the error, code might be more useful
    Tuesday, April 23, 2013 6:26 PM
  • $InstallPath="N:"

    $releaseDirectory="C:\Source\ABC"

    Copy-Item -Path $releaseDirectory\* -Destination $InstallPath  -Force -Recurse  –Verbose

    Tuesday, April 23, 2013 6:30 PM
  • Not sure if this is the issue, but perhaps try this:

       Copy-Item -Path $releaseDirectory -filter * -Destination $InstallPath  -Force -Recurse  –Verbose


    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    • Marked as answer by NewTo-Net Wednesday, April 24, 2013 1:19 AM
    Tuesday, April 23, 2013 10:27 PM
  •  @Al Dunbar, Thank you very much. I have tried below and it worked.

    Copy-Item -Path $releaseDirectory\* -filter * -Destination $InstallPath -Force -Recurse  –Verbose

     
    • Edited by NewTo-Net Wednesday, April 24, 2013 1:19 AM
    Wednesday, April 24, 2013 1:19 AM
  • although it appears to not cause a problem for you, leaving that "\*" on the end of the -Path parameter is redundant as it is not required. On top of that it is misleading.

    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    Wednesday, April 24, 2013 4:18 AM