Windows Vista Forums

copy-item changing files attributes on network copy failures
  1. #1


    jas Guest

    copy-item changing files attributes on network copy failures

    I came across very strange behaviour in copy-item today. When copying a
    read-only file repeatedly from the network to a local folder the first copy
    works but the second copy fails, however the third copy works. The exact
    same copy-item test using local C: paths works fine. Has anyone else seen
    this behaviour before?

    The example below shows the attribute change after the failed copy.

    PS>gci \\myserver\share\testfile.exe

    Directory:
    Microsoft.PowerShell.Core\FileSystem::\\myserver\share\testfile.exe

    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    -ar-- 17/01/2008 07:45 270336 testfile.exe

    PS>1..10 | %{copy-item "\\myserver\share\testfile.exe" . -force ; gci}
    Directory: Microsoft.PowerShell.Core\FileSystem::C:\Documents and
    Settings\jas

    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    -ar-- 17/01/2008 07:45 270336 testfile.exe
    Copy-Item : The file 'C:\DOCUME~1\jas\testfile.exe' already exists.
    At line:1 char:20
    + 1..10 | %{copy-item <<<< "\\myserver\share\testfile.exe" . -force ; gci}
    -a--- 17/01/2008 07:45 270336 testfile.exe
    -ar-- 17/01/2008 07:45 270336 testfile.exe
    Copy-Item : The file 'C:\DOCUME~1\jas\testfile.exe' already exists.
    At line:1 char:20
    + 1..10 | %{copy-item <<<< "\\myserver\share\testfile.exe" . -force ; gci}
    -a--- 17/01/2008 07:45 270336 testfile.exe
    -ar-- 17/01/2008 07:45 270336 testfile.exe
    Copy-Item : The file 'C:\DOCUME~1\jas\testfile.exe' already exists.
    At line:1 char:20
    + 1..10 | %{copy-item <<<< "\\myserver\share\testfile.exe" . -force ; gci}
    -a--- 17/01/2008 07:45 270336 testfile.exe
    -ar-- 17/01/2008 07:45 270336 testfile.exe
    Copy-Item : The file 'C:\DOCUME~1\jas\testfile.exe' already exists.
    At line:1 char:20
    + 1..10 | %{copy-item <<<< "\\myserver\share\testfile.exe" . -force ; gci}
    -a--- 17/01/2008 07:45 270336 testfile.exe
    -ar-- 17/01/2008 07:45 270336 testfile.exe
    Copy-Item : The file 'C:\DOCUME~1\jas\testfile.exe' already exists.
    At line:1 char:20
    + 1..10 | %{copy-item <<<< "\\myserver\share\testfile.exe" . -force ; gci}
    -a--- 17/01/2008 07:45 270336 testfile.exe




      My System SpecsSystem Spec

  2. #2


    Marco Shaw [MVP] Guest

    Re: copy-item changing files attributes on network copy failures

    jas wrote:

    > I came across very strange behaviour in copy-item today. When copying a
    > read-only file repeatedly from the network to a local folder the first
    > copy works but the second copy fails, however the third copy works. The
    > exact same copy-item test using local C: paths works fine. Has anyone
    > else seen this behaviour before?
    I'll try it out tomorrow. Just for fun, I'll also put in a start-sleep
    -seconds XX on each run if I see the same failures.

    Marco

    --
    Microsoft MVP - Windows PowerShell
    http://www.microsoft.com/mvp

    PowerGadgets MVP
    http://www.powergadgets.com/mvp

    Blog:
    http://marcoshaw.blogspot.com

      My System SpecsSystem Spec

  3. #3


    Marco Shaw [MVP] Guest

    Re: copy-item changing files attributes on network copy failures

    jas wrote:

    > I came across very strange behaviour in copy-item today. When copying a
    > read-only file repeatedly from the network to a local folder the first
    > copy works but the second copy fails, however the third copy works. The
    > exact same copy-item test using local C: paths works fine. Has anyone
    > else seen this behaviour before?

    I tested this with the v2 CTP, and could not reproduce. I'm sorry, but
    I can't try v1 right now, but perhaps someone else can help out.

    Marco

    --
    Microsoft MVP - Windows PowerShell
    http://www.microsoft.com/mvp

    PowerGadgets MVP
    http://www.powergadgets.com/mvp

    Blog:
    http://marcoshaw.blogspot.com

      My System SpecsSystem Spec

  4. #4


    jas Guest

    Re: copy-item changing files attributes on network copy failures

    Thak you for looking, I have the opisite problem and cannot test with the
    CTP version.

    "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
    news:u1Q6JDBZIHA.4828@xxxxxx

    > jas wrote:

    >> I came across very strange behaviour in copy-item today. When copying a
    >> read-only file repeatedly from the network to a local folder the first
    >> copy works but the second copy fails, however the third copy works. The
    >> exact same copy-item test using local C: paths works fine. Has anyone
    >> else seen this behaviour before?
    >
    >
    > I tested this with the v2 CTP, and could not reproduce. I'm sorry, but I
    > can't try v1 right now, but perhaps someone else can help out.
    >
    > Marco
    >
    > --
    > Microsoft MVP - Windows PowerShell
    > http://www.microsoft.com/mvp
    >
    > PowerGadgets MVP
    > http://www.powergadgets.com/mvp
    >
    > Blog:
    > http://marcoshaw.blogspot.com

      My System SpecsSystem Spec

  5. #5


    Marco Shaw [MVP] Guest

    Re: copy-item changing files attributes on network copy failures

    jas wrote:

    > Thak you for looking, I have the opisite problem and cannot test with
    > the CTP version.
    I have an idea though, and will try it with v1 within the next few days.

      My System SpecsSystem Spec

copy-item changing files attributes on network copy failures problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
bug in copy-item of readonly files Leo Tohill PowerShell 0 20 Dec 2008
Can the copy-item cmdlet be used to copy public folders to C: ? JoshGfromPortland PowerShell 8 09 Jun 2008
Getting Copy-Item to display messages (like the old COPY command in CMD.EXE) ?? Marc Scheuner PowerShell 15 26 Oct 2007
copy files with AD attributes in name?? steveb PowerShell 6 17 Sep 2007
Copy-Item or Copy-ItemProperty and Remote Registry. Brandon Shell PowerShell 1 09 Jan 2007