2

I mapped a webdav folder with new-psdrive, cd to a folder, then try to copy one file to a local folder. The script code (draft) is the following:

New-PSDrive -Name WEBDAV -PSProvider FileSystem -Root "\\testserver@SSL\davwwwroot\myApp"
cd WEBDAV:
cd "notes\user"
Copy-Item -Path ".\important.txt" -Destination "c:\temp"

What I see, that after the Copy-Item a new empty FOLDER "C:\temp\important.txt" is created. Not a file. When I change the "copy-item" command to "robocopy" it works perfectly. I am wondering what is wrong with the copy-item... How could I use it to do the work?!

Zoltan Hernyak
  • 989
  • 1
  • 14
  • 35
  • 2
    have you confirmed that the source is NOT a dir? if you do `Get-Item` on it and then run `.GetType()` on that ... what does it report? – Lee_Dailey Jul 06 '20 at 13:42
  • which powershell version and platform are you referring? cannot reproduce with Win10 – Falco Alexander Jul 06 '20 at 15:36
  • Mapped as W: and still the same. Powershell version is 5.1.18362.752, it is a Windows 10 Enterprise build 18363. The webdav server is a "our-own" webdav server, our IT team developed and implemented the webdav protocol on it. The LS cmdlet just before the copy-item lists the important.txt as a file item: LastWriteTime : 10/17/2019 10:22:51 AM Length : 33490521 Name : important.txt – Zoltan Hernyak Jul 06 '20 at 17:36
  • Interesting, the get-item says "PSIsContainer : True", and "Attributes : Directory Mode : d-----" There should be the problem! Hm! Thanks for the question @Lee_Dailey! May the protocol implementation is bad :( – Zoltan Hernyak Jul 06 '20 at 17:39
  • 1
    @ZoltanHernyak - that is your problem ... the source item seems to be a dir. [*grin*] that needs to be fixed ... – Lee_Dailey Jul 06 '20 at 17:42

1 Answers1

2

simply specify the file name:

Copy-Item -Path ".\important.txt" -Destination "c:\temp.txt"
Falco Alexander
  • 3,092
  • 2
  • 20
  • 39