OneDriveMapper automatically map your OneDrive for Business upon login

This script maps your Onedrive / Sharepoint / Teams document libraries to driveletters (or shortcuts). It can be used in any environment (VDI, RemoteApp, w10 etc).

4.6 Star
66,342 times
Add to favorites
Office 365
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Suggestion : user config file
    4 Posts | Last post January 16, 2017
    • Hi Jos.
      Congrats for your great job. 
      One little suggestion : why not provide an access to a config file to store the users additionnals libraries, one for each user. The  trick with the ad groups is good but at each udapte of your script, whe have to modify it. 
      A last comment : this file should be a .ini rather than a xml. We use RES (like many people), and RED can modify .ini files and append keys dynamically.
    • Hi Chris,
      that's already on my roadmap, and it'll be web based. So, you'll build configs (as many as you like) in a web portal, and onedrivemapper can then be distributed as MSI with a single extra parameter (the config ID). 
      Hope to have that testable this month or early february. You can then opt to host configs yourself, or pay me to do it for you.
    • very good new . Can't wait. 
      But, Why not combine this with a little bit more intelligence in you usergroups logic. you could for exemple, lookup for one or 2 futher properties of the Group Class and determine if they should be treated and wich will be the Sharepointmapping, the label and the letter and then do all the stuff automatically. 
      I think this could be done easy in you existing script.
      This functionality and the web configs togteher can cover allmost all needs.
    • Good idea, I will :)
  • logs in but wont connect drives
    2 Posts | Last post January 12, 2017
    • Using the script on RDS server 2016. Trying to map the user's onedrive folder in sharepoint to a drive letter. The script logs in ok, and in debug mode we can see it logging into O365 correctly.  
      However even though its logged in it wont map the drives.
      Keeps retrying at "attempting to connect username at https://{mydomain} and then gives up saying failed to detect username from URL for over 62 seconds. 
      Thing is the URL is wrong, because it should be the URL for the onedrive folder, not sitepages.
    • Hmm, did you set up a custom home page? When you browse to, do you end up at your Onedrive for Business? Because that is what the script attempts to get to Onedrive so it can parse the username from the URL, as this doesn't always match the UPN (some people seem to somehow get divorced or married :)).
  • Impersonation
    5 Posts | Last post January 11, 2017
    • Hello Jos,
      Very nice script indeed. I was wondering if the script can handle impersonation. Use case: a customer of mine want to archive old data from MyDocs to users' OneDrive location. A central server would map user's OneDrive and archive files. We want to do this serverside to make it more manageable. Clientside would mean that the archivation tasks would be done by clients..
      Any help would be greatly appreciated!
    • We setup impersonation by creating a Service Account and granting it access to all OneDrive Site Collections:
      So in essence we want to map a user's OneDrive using the Service Account credentials.
    • Yes, that is certainly possible with a few small modifications. Since it is the svc account logging in, it would need to know the onedrive url's of the users you're archiving to and map those, instead of the svc account's onedrive url. The subdomain ( is the same so no additional cookie needed.
    • How should I put the parameters in my Use Case. I tried some different things, but am kinda stuck.
    • You can email josliebennu for support, or in this case, a customized version (add the right characters between sl and nn).
  • THANKS!!
    1 Posts | Last post December 27, 2016
    • Just wanted to say thanks for this awesome script. warnings/errors led me to the right configuration easily and now I can work with ODfB as I've always wanted. Great work.
  • Script Doesn't Start Internet Explorer
    4 Posts | Last post December 16, 2016
    • Hi Jos,
      I've set the debug mode to true, but it doesn't actually start Internet Explorer and the drives aren't mapped at all. I've fiddled about with the settings, but I get an output like this:
      Script elevation level: User
      NOTICE: you are running the latest (v2.49) version of OnedriveMapper
      WARNING: KB2846960 is not installed on this machine, if you're running IE 10 on anything below Windows 10, you may not be able to map your drives until you install KB2846960
      NOTICE: HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Security HKLM only not found in registry, your zone configuration could be set on both levels
      NOTICE: found in IE Trusted Sites on user level
      NOTICE: found in IE Trusted Sites on user level
      NOTICE: * found in IE Trusted Sites on user level
      WARNING: HKLM:\Software\Policies\Microsoft\Internet Explorer\Main\DisableFirstRunCustomize not found or not set to 1 registry, if script hangs this may be due to the First Run popup in IE
      userLookupMode is set to 2 -> checking Active Directory email address
      ERROR: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive or Sharepoint site
      WARNING: Maximum file upload size is set to 48 MB
      Not mapping O4B because dontMapO4B is set to True
      no unmapped or incorrectly mapped drives detected
      OnedriveMapper has finished running
      Restarting Explorer.exe to make the drive(s) visible
      Detected running Explorer processes, attempting to shut them down...
      Stopped process with handle 7596
      Any help with this would be greatly appreciated. 
    • I'm afraid I don't have any suggestions, I'd need to doesn't seem to log/reach the point where it should start an IE COM object.
    • Thanks, Jos. I realised I had set dontMapO4B to True and so it didn't open up IE at all. 
      I've now set it to False and it launches IE. 
      However, I now have another issue where it uses "" as the base URL, whereas it should be using "". Is there a way to change this? I can see other users have this setup, but I haven't seen a post explaining how they did it. 
    • Why is that an issue? Does the user have a license for Onedrive for Business? Otherwise that url won't work, and the script won't do it's job properly.
  • Mapping cannot continue because we could not log in to Office 365
    4 Posts | Last post December 13, 2016
    • Hi Jos,
      I have successfully setup the script for 15usrs in my office but one user. I do not think that there is a problem with the computer / IE as I get the same error when I try to log in to another working computer with her profile. This user profile has been created recently and following is the error log. 
      KB2846960 detected as installed
      WARNING: HKLM:\Software\Policies\Microsoft\Internet Explorer\Main\DisableFirstRunCustomize not found or not set to 1 registry, if script hangs this may be due to the First Run popup in IE
      userLookupMode is set to 1 -> checking Active Directory UPN
      ERROR: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive or Sharepoint site
      WARNING: Maximum file upload size is set to 48 MB
      Adding to mapping list: P: (\\***\DavWWWRoot\personal\)
      Adding to mapping list: A: (\\***\DavWWWRoot\dev)
      P: is not yet mapped
      A: is not yet mapped
      Base URL: https://*** 
      autoKillIE enabled, stopping IE processes
      Stopped process with handle 15116
      Stopped process with handle 12396
      autoProtectedMode is set to True, disabling ProtectedMode temporarily
      Zone 0 was set to 3, setting it to 3
      Zone 1 was set to 3, setting it to 3
      Zone 2 was set to 3, setting it to 3
      Zone 3 was set to 0, setting it to 3
      Zone 4 was set to 0, setting it to 3
      Starting logon process at:
      Detected running explorer process
      Login attempt at Office 365 signin page
      Found sign in elements type 1 on Office 365 login page, proceeding
      Found sign in elements type 2 on Office 365 login page, proceeding
      Found sign in elements type 3 on Office 365 login page, proceeding
      attempting to trigger a redirect to SSO Provider using method 1
      Signin Option persistence selected
      waited for more than 10 to get redirected by SSO provider, attempting normal signin
      Signin Option persistence was already selected
    • Retrieved user password from cache C:\Users\mspudic\AppData\Roaming\OneDriveMapper.tmp
      We attempted to login without using ADFS, but did not end up at the expected location. Detected url:, expected URL: https://***
      autoProtectedMode is set to True, reverting to old settings
      Setting zone 0 back to 3
      Setting zone 1 back to 3
      Setting zone 2 back to 3
      Setting zone 3 back to 0
      Setting zone 4 back to 0
      OnedriveMapper has finished running
      WARNING: restartExplorer is set to False, if you're redirecting My Documents, it won't show until next logon
    • Did you try to run it in debug mode, so you can see what goes wrong at the login page?
    • Fixed.. When I debug the code, I realized that the user name has been pointed to the local domain (abc@xyz.local). Thus, the login failed to O365 site. I went in to AD and changed the user login name to their public domain(
      Everything worked find with the next login.
      Thanks Jos.
  • Can't get Azure AD to work. No registry files found.
    2 Posts | Last post December 12, 2016
    • Hey Jos,
      We are trying to setup the scripts to use our Azure AD accounts but none of the 3 registry files exist in your script. We recently had our own AD system before we gave it to Microsoft to host on Azure. Do you know what those registry files refer to and if we may need to be looking somewhere else so we can get it to sign in on it's own based on the User's password?
      We have confirmed it is AzureAD and the passwords from AD to Email/Webmail sync fine aka are the same. So it looks like it something to do with:
      userLookupMode is set to 3, but the registry path HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WorkplaceJoin\AADNGC does not exist! Using method 2
      userLookupMode is set to 3, but the registry path HKCU:\Software\Classes\Local Settings\Software\Microsoft\SettingSyncHost.exe\WinMSIPC does not exist! Using method 3
      userLookupMode is set to 3, but the registry path HKLM:\SOFTWARE\Microsoft\IdentityStore\Cache\S-1-5-21-3652272553-2793898406-639975886-3624\IdentityCache\S-1-5-21-3652272553-2793898406-63997
      5886-3624 does not exist! All lookup modes exhausted, exiting
      I did see some of the folder structures like HKLM:\SOFTWARE\Microsoft\IdentityStore\Cache\S-1-5-21-3652272553-2793898406-639975886-3624\ but nothing was any further down then that.
    • Hi William,
      interesting, so you're sure you're AzureAD Joined? Not Azure Domain Services joined (or another traditional AD Join form?). 
      Perhaps you found a new niche, can you do a search for your user's UPN in the registry under HKLM:\SOFTWARE\Microsoft\IdentityStore and see if you find anything? 
      Or throw me an export of the registry if you trust that, josliebennu (put the right chars between sl and nn). We'll probably have to add a new detection method for your user's UPN.
  • NET error when mapping drive
    2 Posts | Last post December 08, 2016
    • Hi. I am trying to run this script in a locked down RDS environment. This is the error I get. Any suggestions?
      Mapping target: \\\DavWWWRoot\personal\xxxxxxxxxxxxxxxxxxx_co_nz\Documents
      failed to contact X: after mapping it to \\\DavWWWRoot\personal\xxxxxxxxxxxxxxxxxxx_co_nz\Documents, check if the URL is valid. 
      Error: The term 'NET' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 
      Any suggestions?
    • You seem to be blocking the NET USE command (an executable that comes natively with windows).
      Most likely a group policy, perhaps applocker or one of these settings:
  • OneDrive performance
    2 Posts | Last post December 02, 2016
    • When using the mapped drive for OneDrive the first time and copied some data to it, it was very slow. It took several times longer than it show have with or bandwidth and other Internet uploads. Is that a usual behavior and did anyone noticed that too?
    • webdav is slow, it's a limitation of the protocol and client, but there are a few ways to tweak it to be faster, some of those are in the faq on my blog, others are easy to google :)
  • mapping fails with Okta ass SSO
    9 Posts | Last post December 01, 2016
      ADFS Control found, we were redirected to: https://"mycomp"
      ADFS did not automatically sign us on, attempting to enter credentials at https://"mycomp" asking user for password
      Failed to find the correct controls at https://"mycomp" log in by script, check your browser and proxy settings or modify this script to match your ADFS form. Error details: You cannot call a method on a null-valued expression.
    • Check the inline comments and script configuration, it has specific instructions on Okta
    • Hi Jos,
      Thank You I actually made changes before like:
      $adfsLoginInput        = "user-signin"           #change to user-signin if using Okta
      $adfsPwdInput          = "pass-signin"           #change to pass-signin if using Okta
      But I had adfs button forgotten to change:
      $adfsButton            = "signin-button"            #change to singin-button if using Okta
      Now I get some sort of logon issue after entering the password. 
      We attempted to login with ADFS, but did not end up at the expected location. Detected url: https://"mycomp", expected URL: https://"mytenant" .
      If you like to see the config and log let me know how I can send it to you.
    • what do you see in debug mode? The logs won't help much as I don't have an Okta instance to test / verify this against, support for Okta is based on a single remote session I once had with a company that needed support for it. Okta should redirect to Office 365 after a succesful signin, if it doesn't, additional changes to the script will be required to make it work.
    • It opens IE goes to the Microsoft Login website with IE, does sort of a log out and then goes to login mask but doesn't enter anything.
    • Sorry but this is a little out of scope, if you want me to log in and check for you, you'll have to contact me directly (josliebennu, but the right characters between sl and nn).
    • Sorry, actually it gets stuck at this stage (at the Microsoft Login page) only when why run the powershell script out of the PowerShell ISE.
      When I run the script normally it logs me in etc. but IE has a popup message:
      "This page is accessing information that is not under its control. This poses a security risk,. Do you want to continue?" If I click yes the script continues and maps the OneDrive as network drive. 
      Is this maybe related to IE going to the company sharepoint to a page that does not exist?
      It fails to load/find:
      Do I have to enable "Access data sources across domains" in IE or is there anotehr way to get rid of that message?
    • That security risk message is not related to the SharePoint mapping, because after removing/disabling the sharepoint mapping I still get that message. I disabled "Access data sources across domains", it was set to prompt. Now it is working.
    • glad to hear :)
111 - 120 of 191 Items