How to Map a SharePoint Online Document Library as a Network Drive?
Requirement: Map SharePoint Online library as a network drive.
How to map SharePoint Online as a network drive?
In SharePoint Online, you can use Map as a network drive to access your SharePoint files in File Explorer on your computer. When you map SharePoint as a network drive, you can manage/upload/download files and folders in bulk using Explorer view, just like they are stored on your local computer. You can open and edit files, drag and drop files, and save files directly to SharePoint. Mapping the SharePoint Online document library as a network drive is necessary to manage the SharePoint site folder structure efficiently in the long run. Here is how to map a network drive to the SharePoint Online document library:
- Go to Windows Explorer on your computer >> Right Click on “Computer” (or “This PC”) >> Choose “Map to network drive”.
- Select the drive letter you want to use >> Enter the URL of your SharePoint Online document library. E.g., Your SharePoint library URL could be https://tenant.sharepoint.com/sites/marketing/Shared%20Documents/. You can also enter the site URL to map a SharePoint Online site as a network drive.
- Choose the “Reconnect at logon”, and “Connect using different credentials” options according to your requirements, and click on the “Finish” button. You may get a sign-in prompt. Enter your Office 365 login credentials, and click OK.
- Click Finish to create a new network drive mapping for the given SharePoint Online document library URL without taking up storage space on your device.
Now, you can access the SharePoint Online document library from Windows Explorer (or File Explorer!).
BTW, Microsoft recommends using the Sync feature through the OneDrive sync client, instead of mapped drives for performance and data consistency reasons. Furthermore, it leads to issues like version history being lost, and features like metadata, alerts, etc. won’t be available.
Common Errors and Solutions:
Error: “The mapped network drive could not be created because the following error has occurred. Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.”
Solution: Make sure your SharePoint Online site URL is added under the “Trusted Sites” zone of the browser security settings (Open Internet Explorer >> Tools Menu >> Internet Options >> Security Tab, Trusted sites zone has your site added and “Automatically log in with current user name and password” configuration set!). Also, the WebClient service must be started in the Services console (Services.msc). Otherwise, You may get the below error message! This error also happens when the user sessions expire! Just log in to SharePoint through Internet Explorer (any other web browsers like Firefox or Google Chrome don’t work!) to re-establish the session.
If you get the same error event after setting the above configurations, apply this KB: Error when you open a SharePoint Document Library in Windows Explorer or map a network drive
Users must have at least “Read-only” permission to the Site level to be able to open the document library in Explorer view! So, if you granted them access at the file/folder/library level, Add them to the site level too!
Here is the Microsoft article on troubleshooting issues with mapping network drives: Troubleshoot mapped network drives that connect to SharePoint Online
PowerShell to map a network drive in SharePoint Online
To Map a SharePoint Online Document library to a network drive using PowerShell,
#Variable
$LibraryPath = "https://crescent.sharepoint.com/sites/p/salaudeen"
#Map Path as Network Drive
$Network = new-object -ComObject WScript.Network
$Network.MapNetworkDrive('R:', $LibraryPath)
Once executed successfully, you can see the given path mapped as a network drive from File Explorer.
You can use the New-PSDrive cmdlet to access the file system location, which can be remote or on a local computer.
#Variable
$LibraryPath = "\\crescent.sharepoint.com@SSL\DavwwwRoot\Sites\p\Salaudeen"
#Virtually map SharePoint Online Folder as PSDrive
New-PSDrive -name "R" -Root $LibraryPath -PSProvider filesystem
This doesn’t appear in File Explorer, But you can access it through PowerShell.
Getting Error?
By the recent security updates, The above methods work only when you have an active browser session in place! Otherwise, You’ll see an error:
“New-PSDrive : The operation being requested was not performed because the user has not been authenticated”.
I tried implementing the fix from https://docs.microsoft.com/en-us/troubleshoot/windows-client/networking/error-access-network-drive-mapped-web-share, but that didn’t help for some reason. So, as a workaround, you must either login to the site through Internet Explorer or handle it in PowerShell! E.g.,
#Parameters
$LibraryPath = "https://crescent.sharepoint.com/sites/Marketing/Branding"
$UNCPath = "\\crescent.sharepoint.com@SSL\DavwwwRoot\Sites\Marketing\Branding"
#Establish a browser session
$IE = Start-Process -file iexplore -arg $LibraryPath -PassThru -WindowStyle Hidden
Sleep 15
$IE.Kill()
#Map a PowerShell Drive
New-PSDrive -name "R" -Root $UNCPath -PSProvider filesystem
You can also add SharePoint to file explorer under quick links as in How to Add SharePoint Document Library to “Quick Access” in File Explorer?
It’s worth noting that when you map SharePoint Online as a network drive, you’re only able to access the files and folders that you have permission to. Additionally, you need to keep in mind that if you don’t actively use the mapped drive, it will time out after a period of inactivity, and you have to renew the session by logging into the web browser.
In summary, mapping a SharePoint Online site as a network drive allows you to access and work with your SharePoint files and folders just like you would with files and folders on your local computer. By following the steps outlined in this article, you should be able to map a SharePoint Online site as a network drive and access and work with your SharePoint files and folders using Windows Explorer.
What’s easiest way to refresh connection without I.E.? My employer pushed everyone to Edge this week and now I can’t connect to any of my mapped SharePoint Online directories…
Voici comment y parvenir https://support.microsoft.com/fr-fr/microsoft-edge/mode-internet-explorer-dans-microsoft-edge-6604162f-e38a-48b2-acd2-682dbac6f0de
hi, each time i tried to connect my sharepoint as a mapped drive it asked for the username and password,
on the end it gave an error msg. “the device attached to the system is not function”
I have problem with the mapping. In windows explorer, it show the folder is empty. But the files is there when view from browsers. Pl assist.
Hi – I am looking for some help.
1. I need to map the Sharepoint online as Network drive via XenApp. Tried the below code on our powershell script which used to open the file explorer thru XenApp. Output: Only its accessible when i have an open session one my local/app server Spaas drive.
2
3
4
5
6
#Variable
$LibraryPath = “https://sp16.spaas*********/sites/*******”
#Map Path as Network Drive
$Network = new-object -ComObject WScript.Network
$Network.MapNetworkDrive(‘R:’, $LibraryPath)
2. Need small script where it will Create/write a log into this Sharepoint online space
Hi,
This is working by now with IExplorer.exe, does someone know if there is a way of getting this switched to Edge?
The moment MS is closing IE on the system, or even removing it, a lot of those connections are screwed…..
Thanks
Sebastian
There is a compatibility mode in Edge that uses iexplore. I also use IEtab in Chrome. Both of these methods work for getting authorisation / connection to the sharepoint drives
have you ever tried to Map a SharePoint Online Document Library as a Network Drive using GPO on windows server 2012?
Did anyone solved the problem reported abovfe?
Workaround added to the post.
I get this message, any ideas?
The operation being requested was not performed because the user has not been authenticated.
You need to have an active browser session! Fix appended to the article.
Hi, how are you? I hope well.
I stumble upon your post and was very pleased.
I have a question: Can I do this procedure for SharePoint sites that requires user authentication?
Every time the user logs in the mapping need’s to be done. But using Microsoft Teams is out off question. We found a way off doing by Group policy, but needs opening SharePoint in IE compatibility mode on Edge. My wish were to do all this in one single script. But the authentication part has become.
Thank you anyway.
Make sure you have “UsePersistentCookiesForExplorerView” set. More info here: Fix “View in File Explorer” missing in SharePoint Online Issue
Will this method work even with the end of Microsoft 365 support in Internet Explorer?
This feature depends on WebDav! I tested it in a PC without Internet Explorer and found it works.
I am getting below error
The network name cannot be found.
At C:\Users\Rakesh.Menon\Desktop\MapNetworkDrive.ps1:23 char:1
+ $net.MapNetworkDrive($drive, $LibraryPath, “true”)#, $user, $cred.Get …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException
Looks the $LibraryPath is not resolved! Check if you are able to browse to it.