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
(112)
64,969 times
Add to favorites
Office 365
2/3/2019
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Using script with ADFS
    16 Posts | Last post March 30, 2016
    • We are using ADFS 3.0 with our O365. I have only been able to get the script to work by catching IE at some point and selecting "keep me signed in". If I don't and I just let ADFS pass me through, I get logged in the browser (successfully see in debugging mode) but the script will throw "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."
      Do you have any suggestions on how to get this to work seamlessly with ADFS? Almost there!
    • Your saying the script is not checking the 'keep me signed in' checkbox? (when running in debug mode).
      
      Does the log file tell you anything? :)
    • I thought that was what was happening but haven't been able to reproduce a successful login. Fails pretty much every time I have tried. With debugging turned on I can see it bring up IE, force a logoff I'm assuming (says you have logged off) then logs me into OneDrive (I get no prompts because using ADFS). Then it logs me off again and back. Almost like twice. Then I get the error message. Logging into OneDrive manually works without issue. ADFS logs me in each time and working as expected. If I go to me address https://thelogchurch-my.sharepoint.com I get right into my personal OneDrive space.
    • Last part of log file:
      
      Failed to find /personal/ in the URL: https://thelogchurch-my.sharepoint.com/_layouts/15/start.aspx#/mysiteredirect.aspx, waiting 5 seconds and trying again
      
      Detected user: test123_logchurchpa_org
      
      Current location: https://thelogchurch-my.sharepoint.com/personal/test123_logchurchpa_org/_layouts/15/onedrive.aspx#AjaxDelta=1&isStartPlt1=1459047311879
      browsing to Sharepoint to validate existence and set a cookie
      Session established, attempting to map drive(s)
      
      Mapping target: \\thelogchurch-my.sharepoint.com@SSL\DavWWWRoot\personal\test123_logchurchpa_org\Documents
      
      Failed to map O: to \\thelogchurch-my.sharepoint.com@SSL\DavWWWRoot\personal\test123_logchurchpa_org\Documents, error: 2 System error 224 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.
      
      
      
      autoProtectedMode is set to True, reverting to old settings
      Setting zone 0 back to 0
      Setting zone 1 back to 3
      Setting zone 2 back to 0
      Setting zone 3 back to 0
      Setting zone 4 back to 0
      OnedriveMapper has finished running
    • Lastly, I do have the two below URLs added to my Trusted Sites in IE and I have it configured for User Authentication - 
      "Automatic logon with current user name and password"
      
      https://thelogchurch-my.sharepoint.com
      https://thelogchurch.sharepoint.com
    • then this is where the problem is:
      
      "then logs me into OneDrive (I get no prompts because using ADFS)."
      
      In other words, you were logged off from ADFS, but not from Sharepoint Online, because you can navigate there directly without prompts. 
      
      You need to be truly logged out, I've seen this before even without ADFS but haven't had time to dig into it. Basically, you have to be fully logged out before running the script.
      
      Also see this KB by MS: https://support.microsoft.com/en-us/kb/2507767, probably mostly step 5 since the script already handles step 4.
    • And User Authentication - 
      "Automatic logon with current user name and password" should not be necessary for sharepoint, only for your ADFS FQDN. ADFS then signs you in and forwards the ticket to Sharepoint Online.
      
      And ADFS should be in the local intranet zone
    • This is basically a list of steps I've taken. Even recorded a screen video if interested.
      
      Added the following URLs to my Trusted Sites
      •https://*.microsoftonline.com 
      •https://*.sharepoint.com 
      •https://*.outlook.com
      •https://*.lync.com 
      
      Logon Options for trusted sites - Not Configured (Defaults to "Automatic logon with current user name and password")
      
      Added URL to ADFS to Intranet Sites
      https://adfs.logchurchpa.org
      
      Logon Options for Intranet sites - "Automatic logon with current user name and password"
      
      Log in using new user profile
      Launched OneDrive URL manually - https://thelogchurch-my.sharepoint.com (ADFS logs me in successfully automatically).
      Click on "Sign Out". (ADFS shows "You have successfully signed out")
      Even visit https://login.microsoftonline.com/logout.srf to sign out for good measure.
      Delete all Browser History/Temp files
      Close Browser and reopen.
      Kill (End Process Tree) for iexplore.exe.
      
      Launch script (in debug mode)
      IE launches https://login.microsoft..... says "You signed out of your account".
      I then see the URL change to my ADFS URL and then i end up in my personal OneDrive space (https://thelogchurch-my.sharepoint.com)
      Page almost refreshes or loads the OneDrive page again?? But i end up starring at my OneDrive files again.
      Then error message comes up: "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."
      
      Is this still thinking I'm logged in somehow???
    • What if you skip the first time accessing Onedrive and use a clean profile and run the script?
      
      I'm missing the part where it has to go from login.micr... to your adfs server. That usually only happens if *.sharepoint.com thinks you're already logged in. 
      
      So, after the 'logout' that the script does, you should see it go to login.mic..., enter the email and check the box, and then it should automatically go to ADFS, get signed in etc.
    • It totally just dawned on me that we have "Sign-In Acceleration" turned on for our tenant. This allows for "home realm discovery" for our internal users and therefore they don't have to type in their UN when going to the https://thelogchurch-my.sharepoint.com. So basically it will hit login.microsoft.com, recognize the federation and no UN will be required, hands off to ADFS and puts you on the SharePoint page with hardly any user interaction. Pretty seamless. 
      
      Links for enabling Sign-In Acceleration:
      https://support.office.com/en-us/article/Enable-auto-acceleration-for-your-SharePoint-Online-tenancy-74985ebf-39e1-4c59-a74a-dcdfd678ef83
      
      https://msryanph.wordpress.com/2015/02/20/sharepoint-online-sign-in-acceleration-sso-for-spo/
      
      With that being said - Will this script work with this type of setup?
    • Ah that clears up the confusion and explains why you never see the logon page. I didn't know about Auto-Acceleration. For now, the script will not work if you have Auto-Acceleration enabled.
      
      I do see a whr variable is added to the url to identify it as such, this offers potential for a fix, but I do not have an ADFS environment where I can turn Auto-Acceleration on, so I cannot develop / test a fix right now.
      
      If you need help badly, build a 'safe' VM for me and I'll log on to it and develop a fix in your environment.
    • This seems to actually be a setting that's configured on the SharePoint side for the tenant. This wasn't actually something I did on the actual ADFS server. 
      
      I don't have a problem with you taking a look at the setup in our environment. What would you need?
    • Errr VM hostname, login and password for the VM and login and password for the test user in Office 365. You've already supplied the rest I think :)
    • And of course a safe place to send: josliebennu, add the right characters between sl and nn to get my email address.
    • Alright. I sent you a message. Let me know if you received it.
    • For whoever runs into this: I took a look at what Auto-Acceleration does in Steve's environment and added functionality to v2.28 of OnedriveMapper to handle it properly :)
  • Failed to browse to the Office 365 Sign in page
    4 Posts | Last post March 22, 2016
    • Hello,
      
      we are getting the following error:
      
      Failed to browse to the Office 365 Sign in page, this is a fatal error The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))
      
      ERROR: attempt to navigate caused the IE scripting object to be nulled. This means your security settings are too high (1).
      
      I had tried our tenant name by itself, with .onmicrosoft.com and and with .sharepoint.com at the end and results are the same.
      
      In PS window it says
      
      Could not get dispatch ID for Quit (error: 0x80010108)).
      At C:\Users\romang\Desktop\OneDriveMapper_v2.27 (2)\OneDriveMapper_v2.27.ps1:319 char:5
      +     $ie.Quit() | Out-Null
      +     ~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (:) [], MissingMemberException
          + FullyQualifiedErrorId : System.MissingMemberException
      
      What am I doing wrong?
      
      
      Thanks,
      
      Roman
    • Please post your config and the full log file (obscure what is needed), or email it to me (see earlier comments for my email address). 
      
      You're most likely running into Protected Mode being enabled/blocking you.
    • It started working this morning out of the blue after reboot... Thanks for getting back to me.
    • could be conflicting group policies then...make sure the safe list / protected mode settings are executed before the script executes :)
  • Error Occured while reconnecting???
    7 Posts | Last post March 17, 2016
    • Hey Jos,
      
      Im now having another issues with the script.  when the user logs in, they see the onedrive mapping, but gets an error while reconnecting.  saying access denied.  was working great yesterday..  not sure what could have changed.  
    • So, I went into the registry and removed the mapped drive.  now everytime I log in, the O365 login page comes up saying I was signed out.  doesn't really let me log in, but then the window disappears. we don't use ADFS. any help would be appreciate.. have a huge rollout next week. 
      
      this is the log:
      
      Script elevation level: User
      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: fidelcoguide-my.sharepoint.com found in IE Trusted Sites on user level
      NOTICE: fidelcoguide.sharepoint.com found in IE Trusted Sites on user level
      Adding to mapping list: X: (\\fidelcoguide-my.sharepoint.com@SSL\DavWWWRoot\personal\)
      X: is not yet mapped
      Base URL: https://fidelcoguide-my.sharepoint.com 
      
      autoKillIE disabled, IE processes not stopped. This may cause the script to fail for users with a clean/new profile
      autoProtectedMode is set to False, IE ProtectedMode will not be disabled temporarily
      current URL: https://login.microsoftonline.com/login.srf?wa=wsignin1%2E0&rpsnv=4&ct=1458233807&rver=6%2E1%2E6206%2E0&wp=MBI&wreply=https%3A%2F%2Ffidelcoguide%2Dmy%2Esharepoint%2Ecom%2F%5Fforms%2Fdefault%2Easpx%3Fapr%3D1&lc=1033&id=500046&client%2Drequest%2Did=ee7a699d%2De0b2%2D2000%2D0911%2Dd4f93f9f908f
      Detected running explorer process
      Login attempt at Office 365 signin page
      attempting to trigger a redirect to ADFS
      Failed to find the correct controls at https://login.microsoftonline.com/login.srf?wa=wsignin1%2E0&rpsnv=4&ct=1458233807&rver=6%2E1%2E6206%2E0&wp=MBI&wreply=https%3A%2F%2Ffidelcoguide%2Dmy%2Esharepoint%2Ecom%2F%5Fforms%2Fdefault%2Easpx%3Fapr%3D1&lc=1033&id=500046&client%2Drequest%2Did=ee7a699d%2De0b2%2D2000%2D0911%2Dd4f93f9f908f to log in by script, check your browser and proxy settings or check for an update of this script
      
      OnedriveMapper has finished running
      
    • Could have several reasons....I noticed you set autoProtectedMode to false, and autoKillIE to false? Try setting those to True first.
      
      If you need quick assistance, you can email josliebennu (add the correct characters between sl and nn) for my skype, but I won't be able to remotely assist you for free. 
    • im not sure what changed, but now it seems to have mapped the onedrive again, but the sharepoint library is not mapping.  I guess the question is, can I use your script to map onedrive AND the sharepoint libraries at the same time, or do I need to run 2 separate scripts? If I run them together, is this correct for my lines?
      
      79 $sharepointMappings = @()
      80 $sharepointMappings += "https://fidelcoguide.sharepoint.com/Management/Shared%20Documents,Management,Z:"
      
      
      
      101 if($sharepointMappings[0] -eq "https://fidelcoguide.sharepoint.com/Management/Shared%20Documents,Management,Z:"){
      
       
    • Yes it can do both at once, you should not have changed line 101, if you set it back to if($sharepointMappings[0] -eq "https://ogd.sharepoint.com/site1/documentsLibrary,ExampleLabel,Y:"){ it should work, although you may have to change %20 to a space character, not 100% sure but try both :)
    • OMG.. I cant believe I made that stupid mistake..  urgh.. okay.  they are mapping now.  thank you so much.  one last question.  If I put this in a login script and a user does not have rights to a shared library, it wont map the ones they don't have access to, correct?  I just want to be sure.   :)
    • Haven't tested that, but even if it would map, the user would see an empty drive or an errot
  • sharepoint libraries not mapping...
    4 Posts | Last post March 17, 2016
    • Hey Jos,
      
      I finally got this working in our hosted environment, however, we are trying to not only map the Onedrive, but also shared document libraries.   It maps the OD fine, but doesn't seem to even attempt to map sharepoint.  any thoughts?  I tried turning debug on, but that doesn't seem to work either.. not getting any messages. 
    • The log file should detail IF it attempts / plans to map the configured Sharepoint library(s) that you configured in line 80 and further of the script.
    • Hey Jos,
      
      this is what I am seeing in my log
      
      ----03/16/2016 15:00:23 OneDriveMapper V2.27 - fidelco_bmcadmin on C61 Session log-----
      lookupUPNbySAM is set to True -> Using UPNlookup by SAMAccountName feature
      
      Script elevation level: User
      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: fidelcoguide-my.sharepoint.com found in IE Trusted Sites on user level
      NOTICE: fidelcoguide.sharepoint.com found in IE Trusted Sites on user level
      Not mapping O4B because dontMapO4B is set to True
      no unmapped or incorrectly mapped drives detected
      autoProtectedMode is set to True, reverting to old settings
      OnedriveMapper has finished running
      
    • looks like you didn't add any sharepoint mappings OR those driveletters are already mapped, which is why it is not proceeding.
  • Access Denied error for OneDrive business
    3 Posts | Last post March 17, 2016
    • Hi Jos,
      
      I am trying to map one Drive for business and gave all the parameters correctly. But in the log it shows this error 
      "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."
      
      Any idea would be much appreciated.
    • Were you perhaps already logged in to Office 365? Run the script in debug mode and see if it does or doesn't check that checkbox.
    • Hey Jos,
      
      Your script is perfect. The error I get is due to some Microsoft issue for which I got the hotfix. After installing it I am able to map the drive well.
      
      Thanks
  • Hi Jos
    2 Posts | Last post March 16, 2016
    • Great ps.  The onddrivemapper has finished running but doesn't show within explorer.  HKCU shows the drive letter of X: and within a cmd session I can call x:?  Any ideas why it's not showing within Explorer.  Windows 10 with dirsync (ADFS).  Also to note with the x: drive mapping back to my onedrive is there away to add another driver letter for O365 site. Say S: going back to https://companydomain.sharepoint.com/sites/Site.  If so could you point me in the right direction on the additional code.
      
      Thanks
    • Hi Boots,
      
      the drive is invisible because you're running the script in elevated mode. I added a workaround for that using a Microsoft KB, but apparently in your case it isn't working? You could try setting restart_explorer to $True.
      
      at line 80 in the script configuration you can add as many sharepoint libraries as you wish to be mapped to driveletters.
  • Can't map
    2 Posts | Last post March 16, 2016
    • Hi Jos,
      I work at a university and would love to get this script working for a lab.  I keep trying but the process keeps aborting.  Can I send you a log/the script and see what I'm doing wrong?  A clue:
      Failed to find /personal/ 
    • You can email the log to josliebennu with the right characters between sl and nn
  • Sharepoint Mapping - Only first layer visible
    2 Posts | Last post March 08, 2016
    • Hello 
      
      I used the script with the noO4B Option. Now the Sharepointmapping is done and i see all my mappings in the Explorer. I can go on the networkdrive and there i see my folderstructure. As soon as i try to go into a Folder, the Folder is empty like i have no permissions to see the Content of the subfolders?
      
      Any ideas to get that fixed?
    • Hmmmm, i haven't seen that before. Is it a standard document library without customization? And you have permissions i assume?
  • One Drive Mapping mirrors the C Drive Space left
    3 Posts | Last post February 29, 2016
    • Hi Jos
      
      Great script!:)
      
      Symptom:
      We have some fairly full C Drives on PCs\laptops. The user tries to copy files from an external USB directly into the one drive mapping. If the files been copied are greater in size that the space left on the C Drive it complains as the One drive mapped drive is mirroring the actual space left on the C: drive.
      
      Just wondering is there any way around of preventing the One drive mapping from mirroring the C Drive and actually showing the real space that is left on One Drive?
      
      
    • I'm afraid that that is a bug in the webdav client which i have no workaround for, sorry :(
    • None the less great script and thanks again :)
  • Unable to find personal
    4 Posts | Last post February 10, 2016
    • Hello Jos, 
      
      I'm looking forward using this awesome script!
      
      We use ADFS and after logging in, the user is redirected to https://DOMAIN-my.sharepoint.com/default.aspx
      I'm not sure how your script retrieves the url to O4B. we get the following log entries:
      
      You were already logged in, skipping login attempt, please note this may fail if you did not log in with a persistent cookie
      Failed to find /personal/ in the URL: https://DOMAIN-my.sharepoint.com/default.aspx, waiting 5 seconds and trying again
      ...
      
      Your help is very much appreciated!
      
      Bart
    • Strange, if I do the exact same (browsing to https://domain-my.sharepoint.com) I always end up at my onedrive URL, OR at the provisioning URL if it wasn't provisioned yet. I've seen the same behavior at numerous other users.
      
      Did you customize the relaying party trust in ADFS somehow? What do you see at the default.aspx page?
    • Correct, apparently we have set another page as homepage in mysites, so the user will end up in https://domain-my.sharepoint.com/default.aspx
      
      I guess this will make it hard to retrieve the O4B url.
    • True, but generally, nothing is impossible, probably just a little customization :)
161 - 170 of 191 Items