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
64,969 times
Add to favorites
Office 365
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Windows Auth for onedrive login.
    2 Posts | Last post February 10, 2016
    • does this script work with windows auth. I have AD Sync for all account instead of ADFS.
    • absolutely :)
  • Mapped Drive Only Visible If Run Manually
    4 Posts | Last post February 03, 2016
    • Hi. This looks to be a great script, but I'm experiencing a problem. When running as a logon script, the log file believes the drive has been mapped successfully but it's invisible. If the same user manually runs the script, the exact same log entries exist and yet the drive is visible.
      I have tried $restart_explorer but it makes no difference.
      Any ideas?
    • Even if you manually restart explorer.exe? And you can see them with a net use in an elevated prompt?
      If so, then my fix for that apparently doesn't work for you for some reason....
      Do the registry keys for the drive under HKCU\Network get populated?
    • Hi Jos,
      Thanks for the reply - weirdly, without changing anything, the drive DOES now appear when run as a logon script but it says it's disconnected with the error
      "Web Client Network: Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the website, and select the option to login automatically. This connection has not been restored."
      In debug mode, I can clearly see your script selecting the login automatically option. The log still suggests that the drive has been mapped successfully, and the same user is able to run the script manually and have the drive available.. 
      I tried adding a 10s pause at the start of the script when it's a logon script in case it was something which wasn't ready but that hasn't made a difference.
      Do you have any other suggestions?
    • I would need your log file to further determine the cause, you can send it to josliebennu where you can insert the proper characters between sl and nn
  • Check group membership?
    3 Posts | Last post February 02, 2016
    • Hi Jos,
      First of all, thank you! This is a such great script, quite efficient and it does what I was looking for.
      I'm wondering, which recommendation would you give me to make the script 'check' the user's permissions for specific SharePoint Sites. So, if the user doesn't have access right for specific SP sites it would avoid mapping that site and would continue with the next one.
      My problem here is that I want to use the same script for different user with different access rights, and want to avoid mapping sites for users that doesn't have access to those.
      Thank you again!
    • Hi Carlos,
      you could add some code to verify there is no 'access denied' error when the script browses to the sharepoint URLs. 
      another method would be to check for group membership or such. I could probably code that in half a day for you.
    • Thanks for the reply. Yes, I managed to add group membership checking to your script using some of the code from this other script: 
      Still, I'm not an expert so you probably have a better solution. Maybe verifying there is no 'access denied' error would be more efficient.
  • Does it work with Windows 10 AD Joined to 365?
    3 Posts | Last post January 29, 2016
    • Hi Jos
      Would this work automatically with a user signing into their Windows 10 device with their Office 365 credentials? 
    • last time I tested with a Azure Workplace Joined machine (which I assume you mean), was in a preview build. At the time it worked fine :) Let me know if it doesn't and I'll work on that.
    • tested today, worked without any prompts, full SSO.
  • Script Successful, Mapped Drive not Visible
    2 Posts | Last post January 28, 2016
    • Hi there,
      Firstly thanks for this script looks incredibly useful however I am running into some issues on Windows 7.
      The script says it has completed successfully with no errors, however the drive does not show up. There is also no drive letter in HKCU\Network. Any ideas on what might be causing this?
      Any help greatfully received.
    • is it visible in an elevated prompt? Did you run the script UNelevated? 
      And running v2.25?
  • Mail merge
    2 Posts | Last post January 23, 2016
    • hi there do you know if this will allow mailmerge with a /xls data source stored on sharepoint? at present this isnt supported with office 2013 and SP Online
    • No, I'm afraid Office seems to realize that it is actually a HTTPS connection and throws an error. There are some workarounds, but I'd recommend converting the XLS to a Sharepoint List.
  • Username not found
    5 Posts | Last post January 21, 2016
    • Hi, im really excited about this excellent script but have unfortunately not yet managed to get it to work.
      I think we have a fairly standard O365 setup with the UPN matching between on premise and the cloud and have ADFS implemented (this i think is "skinned").
      I think i have filled in the correct script parameters but the log file is showing username not found at the end.  
      Would appreciate any suggestions you may have.
    • try running it in debug mode, so you can see what happens. It has to end up at the Onedrive page of the user, from where it will get the proper url to map to.
      other than that I'd need a full Problem Step Recording + logfile to help you out...
    • Thanks, i have tried the debug and its does not open the web page correct, just get page cannot be displayed on the URL.
      How do i do the problem step recording please?
      Thanks v.much
    • I have now realised with the help of a colleague that i had mis-read the instruction of what to put in the $O365CustomerName.  I have now corrected this and the web browser opens correctly to my one drive, however im still not getting the drive mapped.  Please can you clarify what should go in the two $sharepointmappings lines as i have left them unchanged but dont actually want to map any sharepoint libraries and there is definitely an error related to this in the log.  However when i comment either of the lines out i get an error in the powershell window.
    • The default settings do not map anything to Sharepoint, the 'default' url as configured in the script isn't actually mapped by the script, it is just an example. You can leave it or remove it, but that won't cause an error. Removing the line with $sharepointMappings = @() will of course cause an error.
      Without your (full) logs I'm afraid I won't be able to help you much further, I doubt it is related to Sharepoint, make sure you follow the instructions on my blog (linked in the post).
  • Drive mapping works, but I get a strange error...
    3 Posts | Last post January 20, 2016
    • Hi there.
      The drive mapping works well for me, but I get a strange error on line 280, character 75:
      Exception calling "ReleaseComObject" with "1" argument(s): "Object reference not set to an instance of an object."
      At C:\OneDriveMapper_v2.24.ps1:280 char:75
      +         $Null = [System.Runtime.Interopservices.Marshal]::ReleaseComObject <<<< ($del)
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : DotNetMethodException
      Any ideas? 
    • Don't worry, that's just cleanup, you can ignore that error. It means the 'clean' quit of the com object worked for you, so the 'thorough' cleanup fails since it was cleaned up :)
    • Awesome - many thanks for the excellent script!
  • URL for OneDrive
    2 Posts | Last post January 12, 2016
    • I tried to map users to their respective OneDrive for Business folder.  I tested the script and "O" drive is mapped to $ on DavWWWRoot.  What did I do wrong and where do I fix it?  I specified $sharepointURL   as
    • Hello Mark,
      The sharepointURL is for mapping to a Sharepoint Library. If you're mapping to Onedrive for Business, you should not configure this setting.
      The comments in the script and the manual on my blog should tell you which options to configure with which settings, let me know if I missed anything though!
  • Stop if ADFS does not work
    2 Posts | Last post December 23, 2015
    • Hi,
      We just found your script while searching for a solution not requiring a 'sync' to access OneDrive and we are really happy about it. There's only a few points that could be enhanced/corrected for it to be perfect.
      First, it would be nice to have an option to stop after trying to connect with ADFS. The reason in our case is simply that a user will have a OneDrive associated with his connected upn or simply won't. 
      So we don't want a user without OneDrive to be bothered with a password prompt. As a quick workaround for now, we'll simply call "abort_OM" at the start of "askForPassword" and it should do the work nicely.
      Secondly, on line 232, you have a typo. "OutNull" should be "Out-Null". Otherwise the line is not executed and explorer is not restarted.
      And for the final point, on line 669, that command wrongly assume that this value is absolutely present in the registry. Which is not always the case if the setting never was changed. This causes the script to 'crash' because Protected Mode isn't disabled correctly.
      So we replaced that line with this block of script:
      $curr = Get-ItemProperty -Path "$($BaseKeypath)\$($i)\" -Name "2500" -ErrorAction SilentlyContinue | select -exp 2500
                              $curr = 0
                              ac $logfile "Value in zone $i was not created, it will be created to 3 and reverted to 0 afterwards (Default value)"
      Otherwise, amazing job, that really saved us a lot of time.
      Thank you
    • Hello Martin,
      thanks for the feedback! I have added the feature and fixed the bugs you mentioned. See v2.23's inline changelog for any other changes.
171 - 180 of 191 Items