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


  • Connect without Mapped Drive
    2 Posts | Last post December 01, 2015
    • Nice work on this, exactly what I was looking for. Perhaps instead of mapping a drive, how would you add an option to add it as a network place?
    • You'd have to add it as a shortcut instead of using the NET USE command. An example in VBScript that should be relatively easy to change to Powershell is the following:
      
      Const NETHOOD = &H13&
      
      Set objWSHShell = CreateObject("Wscript.Shell")
      Set objShell = CreateObject("Shell.Application")
      
      Set objFolder = objShell.Namespace(NETHOOD)
      Set objFolderItem = objFolder.Self
      strNetHood = objFolderItem.Path
      
      strShortcutName = "Finance Department Public Folder"
      strShortcutPath = "\\atl-finance-01\public"
      
      Set objShortcut = objWSHShell.CreateShortcut _
          (strNetHood & "\" & strShortcutName & ".lnk")
      objShortcut.TargetPath = strShortcutPath
      objShortcut.Save
  • errors to login
    3 Posts | Last post November 23, 2015
    • thank you for your work
      
        I have a problem with the script
      
        I want to use it for map a site or biblioteque as a drive... I get the value for:
      
      $domain             = "contoso.com"                     
      $O365CustomerName    = "contoso"                        
      $lookupUPNbySAM     = $False 
      $forceUserName      = "username@contoso.com" 
      $forcePassword      = "userpass" 
      $autoProvision      = $False
      
      i can't mount de drive and i recive this messages in log file:
      
      WARNING: HKLM:\Software\Policies\Microsoft\Internet Explorer\Main\DisableFirstRunCustomize not found in registry, if script hangs this may be due to the First Run popup in IE
      Possible error: HKLM:\Software\Policies\Microsoft\Internet Explorer\Main\DisableFirstRunCustomize not set
      WARNING: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive
      Waited for 10 seconds to get redirected to ADFS
      waited for more than 10 to get redirected to ADFS, aborting script
      
      
      
      
    • the script open a ie window with the user field "username@contoso.com" but the password field is empty, when the attempts count is finish it close the ie window and abort the script without map the new drive.
    • Hi Esteban,
      
      please try v2.22, this should work now :)
      
      Jos.
  • Few Questions and Thanks
    2 Posts | Last post October 29, 2015
    • Heya Jos, 
      
      I can not say how much you rock man.. There aren't works to describe it right now...
      
      This script has helped me abit, however it has left me with a few Questions.
      
      One being the possible expansion of the script. You see for me I've got no problem with my users using the Syncing app for OneDrive For business, however my issue is the "Library" Link they have to put in when the application first starts. I tried to modify your script a little bit in order to get it to click the  "Sync" button within the Web Browner, but failed. I was wondering if you've got something that would do the job?
      
      For me its bout making it easier for my users, most of them would get alot and wouldn't know where to go.
      
      My next question is if you have noticed really bad transfer speeds by mapping the drive like this? We're on a huge link here, but for some reason i only get an upload speed of about 100kb/s is that normal?
      
      THanks
      RB
    • Thanks Andy :)
      
      I personally haven't tried that, but that's a nice way of making things easier for your users, if it only runs once of course. If I have a bit of sparetime sometime, I'll play around with that.
      
      On transfer speeds: I'm on a 10Mbit connection here, and just transferred a 4.5 GB ISO file to my webdav mapped onedrive and it averaged at about 8 Mbps, so that should be about 1200kb/s...? 
      
      I have noticed the WebDAV client can be very slow if you copy a large amount of small files (I tried copying a photo album with 6000 photo's, that took way longer than it would have in 1 file).
  • Trouble inside RDS / Citrix
    3 Posts | Last post October 06, 2015
    • Hi Jos, 
      Firstly thanks for taking the time to write this script.
      We have it working successfully on our managed locked down clients.
      However if I try and run the script from within our RDS / Citrix environment it isn't mapping the drive.  I see True twice and then it finishes.
      Investigating the logfile the first error is see is as follows:
      
      Failed to browse to the Office 365 Sign in page, this is a fatal error
      ERROR: attempt to navigate to https://[US]-my.sharepoint.com caused the IE scripting object to be nulled. This means your security settings are too high.
      
      Any ideas on what I should be checking ? 
      
      Best Wishes,
      
      Andy
      
      
    • Hi, I resolved this issue. It was because I made a typing mistake in the field $O365CustomerName. 
      
      I have corrected that but I am now getting a different problem. Just running the script in Debug mode.  Would it be possible for me to send you the debug log ? If so what is the best way to do that?
      
      Cheers,
      Andy
      
      
      
      
      
    • Hi Andrew,
      
      You can send the logs to jo19lieben[DOT]nu
      
      replace 19 with the 19th letter of the alphabet and add a @ behind it. And replace [DOT] with the right character ;)
      
      Gotta keep spam away sorry....
  • We attempted to login without using ADFS...
    2 Posts | Last post September 17, 2015
    • Hi - this is predominantly working but getting a few of these errors below (I'm in a non-federated environment):
      
      Login attempt at Office 365 signin page
      attempting to trigger a redirect to ADFS
      1. No login splitter detected.
      We're still on the Office 365 page, no redirect was triggered thus not using ADFS
      2. No login splitter detected.
      We attempted to login without using ADFS, but did not end up at the expected location. Detected url: https://login.microsoftonline.com/login.srf?wa=wsignin1%2E0&rpsnv=4&ct=1442303163&rver=6%2E1%2E6206%2E0&wp=MBI&wreply=https%3A%2F%2Fxxxxxxxxx%2Dmy%2Esharepoint%2Ecom%2F%5Fforms%2Fdefault%2Easpx%3Fapr%3D1&lc=2057&id=500046, expected URL: https://xxxxxxxxx-my.sharepoint.com
      autoProtectedMode is set to True, reverting to old settings
      
      Any ideas?
      
      Also, one other thing - sometimes I get an O: drive with a red cross through it (when it has previously been Ok), I think the cookie has expired at that point but when the script is run it still thinks the O: drive is mapped so aborts - is this something you've seen?
      
      Once again, great stuff.
      
      
    • Hmm, I would need the full config and the full log, and would like to see what happens there in debug mode (with a PSR perhaps). But please use my blog to post that as I can see your email there and contact you if the logs are insufficient to help you.
  • Muliple ID's...
    2 Posts | Last post September 14, 2015
    • Was going to ask if you could take a look at the multiple ID issue but looks like you've already sorted - many thanks for this as I was having to run it in debug mode and ask certain users to manually select the account (only happened for one person but they happened to be important). Great stuff.
    • Glad to hear :)
  • UPN/Email not stores in AD...
    3 Posts | Last post July 10, 2015
    • Jos - Great script and this might seem a strange question but we don't store the email address required in any of the users attributes in AD - I'm going to try and ask for the email when it asks for the password, any pointers?? 
    • Cool. You could copy the CustomInputBox function and assign the value to $userUPN, I'd do some input validation though. To make it pretty, set $objTextBox.UseSystemPasswordChar = $False as well.
    • Yep...doing just that, just a matter of populating $userUPN from the text input...nearly there...cheers.
  • cached credentials
    3 Posts | Last post July 08, 2015
    • Any chance that you'll support the case where cookies cash one or more UPNs used to sign into Microosft on a computer? (resulting in buttons to choose among the accounts instead of username/password field)...
    • It already does in the cases I've tested. (I have 3 cached credentials). This is why the script logs out first.
      
      I do intend to add some additional checks because I've noticed that the new Windows 10 Azure / ADFS Workplace Join also does a form of SSO that currently only works in a 'clean' browser session, even forcibly logging out of both ADFS and O365 doesn't clear the cookie. I'll post an update on my blog when that version is done (I expect this month).
    • Vidar, an update has been posted :)
  • Substring Error
    3 Posts | Last post June 26, 2015
    • Hi Jos, when I run your great script, it give me the following error:
      
      Exception calling "Substring" with "2" argument(s): "Index and length must refer to a location within the string. Parameter name: length"
      In OneDriveAutoLoginAndMap.ps1:467 car:1
      + $userURL = $url.Substring($start,$end)
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : ArgumentOutOfRangeException
      
      The goal seems to be reached because I find my new unit linked to SharePoint and it works but I don't know if error can create some problems.
      
      Do you know how can I resolve this error?
      
      Thank you so much.
      Luca
    • Hi Luca,
      
      This is the part of the script that detects your username from the URL. Because it fails it defaults to your login user name, which is also fine as long as you don't change it :)
      
      Jos.
    • I've fixed this in in version 1.9 :)
  • Error Mapping Drive
    2 Posts | Last post April 22, 2015
    • Hey,
      
      I tried to run your script but failed.
      
      Can you point in the right direction of where the logs are so I can take a look?
    • Hi IceBun,
      
      I'm sorry, technet did not notify me of your comment or I'd have responded earlier. You can find the log by typing %APPDATA% in explorer or in the windows Run menu. 
181 - 190 of 190 Items