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


  • How do view the log?
    2 Posts | Last post June 16, 2016
    • Im getting some errors but dont know how to view the log.
    • it is in the appdata directory, just type %appdata% in explorer
  • always mapping to logged in user
    2 Posts | Last post May 11, 2016
    • For onedrive mapping I had a co-worker insert their username and pwd into the custom login pop-ups.  Authentication worked but the mapped drives are not for that user, but still pointing to my own?  What did that other users authentication accomplish?  Can I make the script use the login credentials instead of that other location it's pulling from?
      
      Thanks,
    • If you are using ADFS, this is simply what ADFS does: it logs you in with the user currently logged into your workstation (SSO)
  • Running at startup Windows 10
    3 Posts | Last post May 11, 2016
    • Hi, I am trying to get this to run at start up via a scheduled task deployed by GP on Windows 10 machines. The task is being deployed okay, but for some reason is not running at login as intended. I can run the scheduled task manually and it works fine. Has anyone else had success with deploying this on Windows 10? it works prefect with Windows 7 via GP. 
      
      Any ideas?
      Thanks
      
    • Only way I got it to work is to run interactively as the user.
    • This is covered in the FAQ on my blog, didn't have room/time to maintain another FAQ here sorry :)
  • Mapped Drive space isn't accurate, Prompts, Sharepoint.
    2 Posts | Last post May 10, 2016
    • Hi, 
      I've had some success using this tool, but have a few questions that I hope you can assist.  
      
      my environment - Win7, ADFS, onedrive, O365, Sharepoint
      
      1. Once the drive is mapped it's not showing the space accurately, it's mirroring the space details of the C:\ Drive.  Anyway to match the 1TB or whatever the user has? 
      
      2. I feel like I am getting one too many prompts.  For example, I am prompted One time from the custom form for a username(O365 UPN doesn't match computer login) then a second custom form for pwd.  While this is happening I also get a security prompt from IE asking for the same details.  Is this for the same thing?  Can one do the job of the other?  
      
      3. The sharepoint documents mapping.  My library has a space in the name, what should my syntax look like?  
      Here's my entry. 
      
      $showConsoleOutput     = $True                     #Set this to $False to hide console output
      $showElevatedConsole   = $True
      $sharepointMappings    = @()
      $sharepointMappings    += "https://ogd.sharepoint.com/site1/documentsLibrary,ExampleLabel,Y:"
      $sharepointMappings    += "https://bw.sharepoint.com/brytest/Shared Documents,brylabel,U:"
       
      
      
      
    • 1: this is by design by Microsoft for webdav drives
      2: that IE prompt is probably ADFS, the script only supports SSO OR Forms-based authentication modes in ADFS, the IE popup can't easily be accessed via script. 
      3: either Shared%20%20Documents or Shared%20Documents should work
  • OneDrive for Business Only?
    2 Posts | Last post May 10, 2016
    • Awesome work, thanks! Do you know if this will work for non-Business OneDrive, like through an outlook.com address?
      
      Josh
    • I'm afraid not
  • Default page in O365
    2 Posts | Last post May 04, 2016
    • Hi,
      
      When I run the script everything work well for a user but it's not working for others. I found a way to fix the problem but I would like to have a solution that does not require user interaction.
      
      When I run the script and the user default login page in Office 365 is OneDrive everything work fine. The users have the default login page with link to all the applications (Word, Excel, etc.) and the script dont seem's able to redirect to OneDrive from here.
      
      The default login page is https://www.office.com/1?auth=2&home=1&from=PortalLanding&client-request-id=f966e422-58be-47ab-bf6c-d5d0b4ba5784
      
      The working login page (oneDrive) is https://csduroy-my.sharepoint.com/personal/user_name_csduroy_qc_ca/_layouts/15/onedrive.aspx
      
      I dont want to change the login page (as the users can choose any apps from there and download Office) but I would love this script to work.
      
      Any tips?
      
    • ah, sure, that's easy to fix, I haven't seen that domain being used as a start page before, just add this line at line 153 of the script:
      
      $finalURLs += "https://www.office.com"
      
      Enjoy ;)
  • Error while mapping One Drive to a network drive
    6 Posts | Last post April 28, 2016
    • Hi
      
          I am using the script to map my One Drive for Business on my desktop. The scripts ends without error. But the drives are not mapped. I had look into the log file and it shows this. Please let me know how to solve it
      
      lookupUPNbySAM is set to True -> Using UPNlookup by SAMAccountName feature
      Script elevation level: Administrator
      Possible critical error: Microsoft Office installation not detected, script may fail
      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
      Possible critical error: onevmw.sharepoint.com not found in IE Trusted Sites on user or machine level, the script will likely fail
      Possible critical error: onevmw-my.sharepoint.com not found in IE Trusted Sites on user or machine level, the script will likely fail
      WARNING: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive
      Adding to mapping list: X: (\\onevmw-my.sharepoint.com@SSL\DavWWWRoot\personal\)
      X: is not yet mapped
      Base URL: https://onevmw-my.sharepoint.com 
      
      autoKillIE enabled, stopping IE processes
      Stopped process with handle 17716
      Stopped process with handle 2016
      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 3, setting it to 3
      Zone 4 was set to 3, setting it to 3
      current URL: https://login.microsoftonline.com/
      Detected running explorer process
      Login attempt at Office 365 signin page
      Found sign in elements type 2 on Office 365 login page, proceeding
      attempting to trigger a redirect to ADFS
      login detected, login function succeeded, final url: https://portal.office.com/Home
      Failed to get the username from the URL for 30 seconds, aborting
      autoProtectedMode is set to True, reverting to old settings
    • You can find my reply at my blog, as you asked there as well (thanks!) :)
      
      I've also uploaded a slightly modified v2.28 which logs more info when it can't find the username.
    • I have tried using v2.29 and still the sam error. Attaching the error log below
      -----04/28/2016 12:31:33 OneDriveMapper V2.29 - graja on 1CLOUD-120 Session log-----
      lookupUPNbySAM is set to True -> Using UPNlookup by SAMAccountName feature
      Script elevation level: Administrator
      Possible critical error: Microsoft Office installation not detected, script may fail
      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: onevmw-my.sharepoint.com found in IE Trusted Sites on user level
      Possible critical error: onevmw.sharepoint.com not found in IE Trusted Sites on user or machine level, the script will likely fail
      WARNING: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive
      Adding to mapping list: X: (\\onevmw-my.sharepoint.com@SSL\DavWWWRoot\personal\)
      X: is not yet mapped
      Base URL: https://onevmw-my.sharepoint.com 
      autoKillIE enabled, stopping IE processes
      Stopped process with handle 8196
      Stopped process with handle 10700
      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 3, setting it to 3
      Zone 4 was set to 3, setting it to 3
      current URL: https://login.microsoftonline.com/
      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 ADFS using method 1
      login detected, login function succeeded, final url: https://portal.office.com/Home
      Attempting to retrieve the username by browsing to https://onevmw-my.sharepoint.com...
      Failed to get the username from the URL for 30 seconds while at https://onevmw-my.share
    • the final part of the log is important, I can't help you if you only post a part of it.
    • Please find the last part of the log
      
      Failed to get the username from the URL for 30 seconds while at https://onevmw-my.sharepoint.com/_layouts/15/start.aspx#/SitePages/Home.aspx, aborting
      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 3
      Setting zone 4 back to 3
      OnedriveMapper has finished running
    • looks like you're redirected to a custom page, instead of the normal Onedrive page. Browsing to https://tenant-my.sharepoint.com usually redirects to Onedrive for Business for that user. 
      
      I'm afraid the script can't be built to handle unexpected situations like that unless I have access to such environments. You can email me at josliebennu (put the right characters between sl and nn) if you want to hire me to customize it for your specific implementation.
  • Unexpected URL
    7 Posts | Last post April 27, 2016
    • I'm getting the following error, but I can 100% confirm I don't have a password issue. Any thoughts? Thanks!!!
      
      We attempted to login without using ADFS, but did not end up at the expected location. Detected url: https://account.activedirectory.windowsazure.com/passwordreset/register.aspx?sspr=1&sspr=1&brandcontextid=O365, expected URL: https://sagu-my.sharepoint.com
    • Looks like you enabled self service password reset for this user but did not register for it yet at the specified url.
    • Perfect, thank you! One more: I have had a couple folks time out the first time when it's looking up the username. I just run it again, and it's fine; but was wondering if I could change that wait time here:
      if($dontMapO4B -eq $False){
          while($url.IndexOf("/personal/") -eq -1){
              Sleep -s 3
              $timeSpent++
              $ie.navigate($baseURL)
              do {sleep -m 100} until (-not ($ie.Busy))  
              do {sleep -m 100} until ($ie.ReadyState -eq 4 -or $ie.ReadyState -eq 0)  
              $url = $ie.LocationURL
              if($timeSpent -gt 10){
                  ac $logfile "Failed to get the username from the URL for 30 seconds while at $url, aborting" 
                  $errorsForUser += "Mapping cannot continue because we cannot detect your username`n"
                  abort_OM 
              }
          }
    • certainly, you could increase the number 10 to, for example, 20, then it would wait for 60 seconds. If this is happening because your users had never accessed onedrive before, I recommend you use O365Migrator to preprovision their Onedrive storage.
    • Awesome; thanks so much!
    • I actually had one more strange thing pop-up. When it lists the size of the drive, it simply copies what is available in C, instead of an accurate limit. Anyway to bypass this? I want to copy a large chunk of data, but can't because windows thinks I don't have enough space.
      
      Thanks again!
    • Hi James, 
      
      i'm afraid that that is a bug or 'feature' in the WebDav client, it's been that way since it exists and I don't know of a workaround.
  • Unexpected URL
    1 Posts | Last post April 26, 2016
    • I'm getting the following error, but I can 100% confirm I don't have a password issue. Any thoughts? Thanks!!!
      
      We attempted to login without using ADFS, but did not end up at the expected location. Detected url: https://account.activedirectory.windowsazure.com/passwordreset/register.aspx?sspr=1&sspr=1&brandcontextid=O365, expected URL: https://sagu-my.sharepoint.com
  • V 2.28 -> error message
    3 Posts | Last post April 07, 2016
    • Hi Jos,
      
      I use the script for mapping a SharePoint library as a drive in a RDS environment.
      The mapping as such is working fine, but the users get the following error-message:
      
      The object invoked has disconnected from its clients. (Exception from HRESULT:
      0x80010108 (RPC_E_DISCONNECTED))
      At C:\xxx\xxx\xxxx\OneDriveMapper_xxx.ps1:344 char:11
      +       if ($ShellWindows.Item($i).FullName -like "*iexplore.exe")
      +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (:) [], COMException
          + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
      
      
      The onedrivemapper.log looks perfectly fine.
      I am using the script you provided 2 days ago.
      
      Do you have an idea how to get rid of this message?
      
      Benni
    • Because of the diversity in implementations out there, the script has two methods to remove the used Internet Explorer objects for login+mapping. You can safely ignore this error. If you don't want the user to see it, I recommend running the script in hidden mode (instructions on my blog).
      
      Alternatively you could nest the second part in a try/catch loop and hide the error that way.
    • Thanks for the feedback.
      ... running smoothly in the background now ...
      
      
151 - 160 of 194 Items