My goal is to map a network drive in Windows to a WebDAV server via PowerShell.

I have a script that automatically creates an Azure VM with IIS installed and WebDAV configured. I can successfully map manually the network drive via Windows Explorer to the WebDAV server (using the option to use different credentials). That confirms that the WebDAV server is configured correctly. I can read and write files, too.

Via PowerShell I have tried to use the command New-PSDrive and get errors as you see.

New-PSDrive –Name $networkDrive –PSProvider FileSystem –Root "http://$serviceName.cloudapp.net/" –Persist
New-PSDrive : When you use the Persist parameter, the root must be a file system location on a remote computer.
At line:1 char:1
+ New-PSDrive –Name $networkDrive –PSProvider FileSystem –Root "http:// ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Z:PSDriveInfo) [New-PSDrive], NotSupportedException
    + FullyQualifiedErrorId : DriveRootNotNetworkPath,Microsoft.PowerShell.Commands.NewPSDriveCommand

OR without the parameter -Persist

New-PSDrive –Name $networkDrive –PSProvider FileSystem –Root "http://$serviceName.cloudapp.net/"
New-PSDrive : The specified drive root "http://webdavservertest3.cloudapp.net/" either does not exist, or it is not 
a folder.
At line:1 char:1
+ New-PSDrive –Name $networkDrive –PSProvider FileSystem –Root "http:// ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (Z:PSDriveInfo) [New-PSDrive], IOException
    + FullyQualifiedErrorId : DriveRootError,Microsoft.PowerShell.Commands.NewPSDriveCommand

As one can see the term "http://$serviceName.cloudapp.net/" successfully evaluates to "http://webdavservertest3.cloudapp.net/".

So, is this the right approach? Should New-PSDrive be capable of mapping to WebDAV servers? If not, any idea to map the network drive via PowerShell?

4 Answers 4


Here is a working example of me mounting the Sysinternals WebDAV site to my S: drive:

[String]$WebDAVShare = '\\live.sysinternals.com\Tools'
New-PSDrive -Name S -PSProvider FileSystem -Root $WebDAVShare

Notice you need to use the UNC format, not the http:// prefix.

Also you need to make sure that the WebClient service is running on your computer.

If you wanted to confirm that a server supports WebDAV, you could do:

(Invoke-WebRequest http://live.sysinternals.com -Method Options).Headers.DAV  

And if that returns something like 1,2,3 then the server supports various versions of WebDAV. (Although the server administrator may have disallowed the Options verb.)

  • This helped me get access to OneDrive directory data for migrating... very helpful. Thanks much!
    – ATek
    May 3, 2021 at 23:14
New-PSDrive -Name F -PSProvider FileSystem -Root "\\\\$FQDN_without_https@SSL/$URI_or_PathTo" -Credential <Username>

Please pay attention for @SSL after FQDN.

This works for PowerShell 5.0.

  • This is also how NET USE internally does it, as one can see with the similar @SSL syntax for a mapped WebDAV network drive in Explorer.
    – Jonas
    Mar 14, 2018 at 7:39

I followed all the above resources and none worked for my attempts to mount my hosted 365 Sharepoint document library. Eventually I mounted it as a shared network location and noted in the properties of that connection the true WebDAV path that you should be using for this.

This connection string allows me to mount and use the Sharepoint library as a drive letter:

function Map-SharePoint
        $cred = Get-Credential "[email protected]"
        New-PSDrive -Name U -PSProvider FileSystem -Root "\\organisation.sharepoint.com@SSL\DavWWWRoot\Shared Documents" -Credential $cred

A note about the path, this will not work if you patch contains %20 for spaces. You need to leave it as is and wrap it in quotes.

  • What do you have to do to workaround the %20 ?
    – Michele
    Nov 27, 2018 at 19:32
  • 1
    Replace the %20 with a space and then put quotes on either end. So use "blah.blah\Shared Documents" instead of blah.blah\Shared%20Documents
    – Patrick
    Nov 28, 2018 at 20:26

I was not able to get the New-PSDrive method to connect to my https site. I used a dos command within powershell wrapped in a test to see if the drive existed.

net use B: https://tu13.DEG3.usae.com/BAD/code /Persistent:Yes

I realize this is not the perfect approach based on the OP but I thought that a work around was worth the post.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .