0

I have written the below script for a WebDav share on a public website. The intention is to list all PDF from a internal network share and move files to the WebDAV share on the website. I can confirm both New-PSDrive mapping are successful. I then move files and the file are removed from source but do not appear in destination.

I am trying to find fault when no error presented. As WebDAV share and not used this before is there something I am missing in logic here ?.

In move Item I have also tried adding the $Path1 then -Destination and $Path but fails. I modify script for local session path like C:\Temp and works fine. Suspect something different for WebDAV Shares.

$user = "webdav"
$pass = convertto-securestring -String 'WebDAV Password' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential($user,$pass)
$user1 = "Domain Account"
$pass1 = convertto-securestring -String 'DOMAIN PASSWORD HERE' -AsPlainText -Force
$cred1 = New-Object -typename System.Management.Automation.PSCredential($user1,$pass1)
[String]$path = '\\constoso.com@SSL/Dav/PDF'
[String]$path1 = '\\Domain\corpdata\PDF'
New-PSDrive -Name WebSite -PSProvider FileSystem -Root $path -Credential $cred
New-PSDrive -Name FilePath -PSProvider FileSystem -Root $path1 -Credential $cred1
Get-ChildItem -Path FilePath: -Include *.pdf -Recurse | Move-Item -Destination $path

No error reported files are not in destination when using WebDAV share can confirm in Get-PSDrive they are successfully mapped and accessible. Move appears to remove from source but not present in destination.

2
  • Can you confirm that the part "Get-ChildItem -Path FilePath: -Include *.pdf -Recurse" works? If so, could you post the return value? Commented Aug 2, 2019 at 8:39
  • you have an error [as mentioned by Maurice van Dorst] that triggers a big red wall of error text for me. this ... >>> Get-ChildItem -Path FilePath: <<< ... is not valid code.**please fix that to match what you are actually running.** Commented Aug 2, 2019 at 14:56

1 Answer 1

1

As you are working with PSDrive cmdlets you'll have to specify the 'Provider' info. In your case the UNC paths belong to the 'Filesystem' provider. So, try changing your 'path' variables like the below,

[String]$path = 'Filesystem::\\constoso.com@SSL\Dav\PDF'

[String]$path1 = 'Filesystem::\\Domain\corpdata\PDF'

Cheers!

~K

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks,Just offsite atm but will test and let you know how I go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.