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


