SharePoint Online Document Library as a Mapped Drive


Looking at the title of this blog post you may think that this is yet another article on how to connect to a SharePoint Online document library as a mapped drive.  But there are very few free solutions for doing this when using ADFS or Azure AD Connect for SSO.  None of the ones I found worked when using Azure AD Connect.

If you are looking for a solution that works with ADFS then checkout Cookie365
https://fabiocuneaz.blogspot.it/

The problem is to obtain the authentication cookie needed to map the drive you must first SSO to SharePoint Online using Internet Explorer (other browsers will not work).  By default the cookie will expire after 5-days, but our users have a fresh Windows login almost daily at which point the cookie will be refreshed by the logon script.  That being said I don't expect the cookie to expire potentially causing a problem with connecting to the mapped drive.  If it becomes an issue I plan to look into running a portion of the PowerShell script as a scheduled task, which can be deployed using a GPO.

Although still in the testing phase here's what I came up with as part of a PowerShell logon script.  So far it is working well, other than the IE window not always remaining hidden.  It seems that the navigate overrides visable=$false.

Replace the value in [ ] with your unique settings.

 #### # Open IE and set cookie  
 $url = "https://[tenant].sharepoint.com"  
 $ie = New-Object -com internetexplorer.application  
 $ie.visible = $false  
 $ie.navigate($url)  
   
 Start-Sleep -s 15  
   
 #### # Map Drives  
 $Net = New-Object -com WScript.Network  
 $rename = New-Object -com Shell.Application  
   
 #### # Map the network drives  
 $Net.MapNetworkDrive("X:", '[Your SPO document library URL]')  
   
 #### # Set network drive friendly name  
 $rename.NameSpace('X:').Self.Name = '[User friendly name]'  

Comments

Popular posts from this blog

My Experience with Microsoft's Local Administrator Password Solution (LAPS)

Microsoft's SharePoint Migration Tool