Edit: Updated 2017-11-22 – People seem to have problems with the New Login experience. Seems Jos has created a new version. Check out:
Needed this for a client that has way to many files for sync and uses windows 7 (which means no select sync).
After having reviewed different solutions such as Mountainduck or Zeedrive I stumbled on this script. It’s awesome. It mounts the drive on startup if its missing and works.
All credits to the script goes to this guy.
Lets get to it:
- Download the script (Check out the Gitlab version, technet is not updated).
- Disable Filelocking.
- Edit the script. You only need to fiddle with the first 20 settings.
Here are the settings that I changed (below), You should read it all and test it properly for your needs. I needed the Personal Onedrive AND a sharepoint document library to be mounted. Also I added the Username/Password straight in the file (I know – bad, but works). There is a possibility to have an external file with U/P. I will update the post when I figure that out.
$driveLetter = "Z:" #This is the driveletter you'd like to use for OneDrive, for example: Z:
$redirectToSubfolderName = "Documents" #This is the folder to which we will redirect under the given $driveletter, leave empty to redirect to the Root (may cause odd labels for special folders in Windows)
$driveLabel = "Onedrive WebDAV" #If you enter a name here, the script will attempt to label the drive with this value
$O365CustomerName = "XXXX" #This should be the name of your tenant (example, ogd as in ogd.onmicrosoft.com)
$dontMapO4B = $False #If you're only using Sharepoint Online mappings (see below), set this to True to keep the script from mapping the user's O4B
$userLookupMode = 1 #1 = Active Directory UPN, 2 = Active Directory Email, 3 = Azure AD Joined Windows 10, 4 = query user for his/her login, 5 = lookup by registry key, 6 = display full form (ask for both username and login if no cached versions can be found)
$forceUserName = 'ADD OFFICE 365 USERNAME' #if anything is entered here, userLookupMode is ignored
$forcePassword = 'ADD PASSWORD' #if anything is entered here, the user won't be prompted for a password. This function is not recommended, as your password could be stolen from this file
$showConsoleOutput = $False #Set this to $False to hide console output
$showElevatedConsole = $False
$sharepointMappings = @()
$sharepointMappings += "https://YOURSUBDOMAIN.sharepoint.com/YOURDOCUMENTLIBRARY,ExampleLabel,Y:"
$showProgressBar = $True #will show a progress bar to the
4. Test the script.
5. If you want to add the script to startup – check out my post How to run a powershellscript on startup .
6. Done! Now the folders will mount using Webdav and runs smoothly. This was tested on Windows 10.