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


  • SharePoint not mounting
    3 Posts | Last post August 18, 2017
    • Hi Jos,
      
      First of, Great script! OneDrive mounting works awesome. But for some reason SP Libraries wont work. No error, nothing. Am I doing something wrong?
      
      ###THIS ONLY HAS TO BE CONFIGURED IF YOU WANT TO MAP USER SECURITY GROUPS TO SHAREPOINT SITES
      if($lookupUserGroups -and $configurationID -eq "00000000-0000-0000-0000-000000000000"){
          try{
              $groups = ([ADSISEARCHER]"samaccountname=$($env:USERNAME)").Findone().Properties.memberof -replace '^CN=([^,]+).+$','$1'
              log -text "cached user group membership because lookupUserGroups was set to True"
              #####################FOR EACH GROUP YOU WISH TO MAP TO A SHAREPOINT LIBRARY, UNCOMMENT AND REPEAT BELOW EXAMPLE, NOTE: THIS MAY FAIL IF THERE ARE REGEX CHARACTERS IN THE NAME
              #    $group = $groups -contains "DLG_West District School A - Sharepoint"
              #    if($group){
              #       ###REMEMBER, THE BELOW LINE SHOULD CONTAIN 2 COMMA's to distinguish between URL, LABEL and DRIVELETTER
              #       $sharepointMappings += "https://ogd.sharepoint.com/district_west/DocumentLibraryName,West District,Y:"
              #       log -text "adding a sharepoint mapping because the user is a member of $group"
              #    }  
              #####################FOR EACH GROUP YOU WISH TO MAP TO A SHAREPOINT LIBRARY, UNCOMMENT AND REPEAT BELOW EXAMPLE, NOTE: THIS MAY FAIL IF THERE ARE REGEX CHARACTERS IN THE NAME
                  $group = $groups -contains "GG_SP_Administrative Ondersteuning_CPR_Write"
                  if($group){
                     ###REMEMBER, THE BELOW LINE SHOULD CONTAIN 2 COMMA's to distinguish between URL, LABEL and DRIVELETTER
                     $sharepointMappings += "https://vitras.sharepoint.com/sites/teams/03/CPR,CPR,P:"
                     log -text "adding a sharepoint mapping because the user is a member of $group"
                  }   
          }catch{
              log -text "failed to cache user group membership because of: $($Error[0])" -fout
          }
      
      Thanks in advance!
      
      Cheers,
      
      Anne
    • O my bad, Pasted the commented and the new part in one. This is my part:
      
       #####################FOR EACH GROUP YOU WISH TO MAP TO A SHAREPOINT LIBRARY, UNCOMMENT AND REPEAT BELOW EXAMPLE, NOTE: THIS MAY FAIL IF THERE ARE REGEX CHARACTERS IN THE NAME
                  $group = $groups -contains "GG_SP_Administrative Ondersteuning_CPR_Write"
                  if($group){
                     ###REMEMBER, THE BELOW LINE SHOULD CONTAIN 2 COMMA's to distinguish between URL, LABEL and DRIVELETTER
                     $sharepointMappings += "https://vitras.sharepoint.com/sites/teams/03/CPR,CPR,P:"
                     log -text "adding a sharepoint mapping because the user is a member of $group"
                  }   
          }catch{
              log -text "failed to cache user group membership because of: $($Error[0])" -fout
          }
      
    • Jos can you delete my comment? I'm now aware that there is information in the links that should not be there. Ill post it again.
  • Logon failures... works after repeated retries
    5 Posts | Last post August 18, 2017
    • Here is a log Jos - this was working fine until the weekend. Prompts for password, fails twice and works the third time - any idea? - Regards, Andrew
      (I can't fit the log in here... how can I send it?)
      I hooked up with you on LinkedIn yesterday - will try that channel...
      Here is key item from the log. Note same password entered each time:
      08/07/2017 12:27:50 | INFO | Retrieved user password from cache C:\Users\xxxx\AppData\Roaming\OneDriveMapper.tmp
      08/07/2017 12:27:54 | ERROR | There was an issue while trying to log in during attempt 1
      08/07/2017 12:27:54 | INFO | Signin Option persistence selected
      08/07/2017 12:27:54 | INFO | asking user for password
      08/07/2017 12:28:01 | INFO | Stored user's new password to user password cache file C:\Users\xxxx.davidson\AppData\Roaming\OneDriveMapper.tmp
      08/07/2017 12:28:03 | ERROR | There was an issue while trying to log in during attempt 2
      08/07/2017 12:28:03 | INFO | Signin Option persistence was already selected
      08/07/2017 12:28:03 | INFO | asking user for password
      08/07/2017 12:28:07 | INFO | Stored user's new password to user password cache file C:\Users\xxxx.davidson\AppData\Roaming\OneDriveMapper.tmp
      08/07/2017 12:28:09 | ERROR | There was an issue while trying to log in during attempt 3
      08/07/2017 12:28:10 | INFO | detected user logged in Tile in IE
      08/07/2017 12:28:15 | INFO | login detected, login function succeeded, final url: https://www.office.com/
      08/07/2017 12:28:15 | INFO | IE login function succeeded
      08/07/2017 12:28:27 | INFO | Detected user: xxxx_davidson_compxyz_org_au
      08/07/2017 12:28:27 | INFO | Onedrive cookie generated, mapping drive...
      08/07/2017 12:28:28 | INFO | Mapping target: \\compxyz-my.sharepoint.com@SSL\DavWWWRoot\personal\xxxx_davidson_compxyz_org_au\Documents
      08/07/2017 12:28:28 | INFO | A drive label has been specified, attempting to set the label for O:
      08/07/2017 12:28:28 | INFO | Label has been set to Onedrive
      08/07/2017 12:28:28 | INFO | O: mapped successfully
      
    • Jos, I think the reason this is happening now is that the Windows 2012 R2 server is falling back to legacy mode (suddenly) for some reason. Can you please run though for me the checks needed to make sure native mode will work on 2012 R2 server? That would be greatly appreciated... - cheers, Andrew
    • I'm getting the same issue. I notice that if I hard code the password, it works fine. However, retrieving the password from the encrypted .tmp file is not working (the file is in the correct spot and it is found by the script).
      
      Any ideas?
    • I found a fix to my issue of being asked for the password multiple times when using an excrypted file (hard coded pw worked fine).
      
      The login URL seems to have changed. With debugging on, I could see the microsoft login page re-load a second time. I copied the URL (which is quite long) and replaced the current one (https://login.microsoftonline.com/login.srf?msafed=0#) in the script with it (https://login.microsoftonline.com/common/oauth2/authorize?client_id=00000006-0000-0ff1-ce00-0000...). The mapping now works and I'm not asked for a password multiple times.
      
      I will not put the whole URL here as I'm not sure what potential user account info it could contain. You can get the URL yourselves as I did though.
      
      I hope this will help others as well. Do let us know.
    • Dear friends,
      I had the same experience with the OnedriveMapper suddenly not working anymore. This morning we found out that it had to do with the new log-in experience of Microsoft for Internet Explorer. I set my log-in back to the old experience and the program is working as it Always did.
  • One Drive is not getting Mapped.
    2 Posts | Last post August 09, 2017
    • Hi Jos,
      We are using onedrivemapper v2.49 to map one drive as Y drive to users. After user logs in to the session mapper runs and asked for the Office 365 password. Once user provided the password after that mapped gets closed and through a message " Mapper cannot continue because we could not log in to Office 365". However user is able to access onedrive by using web portal that means they have the proper access to the onedrive.
      
      Here are some of the logs we have taken. Please help how this can be resolved.
      
      
      ERROR: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive or Sharepoint site
      Adding to mapping list: Y: (\\XXXXXX-my.sharepoint.com@SSL\DavWWWRoot\personal\)
      Y: is not yet mapped
      Base URL: https://XXXXXX-my.sharepoint.com 
      
      Starting logon process at: https://login.microsoftonline.com/login.srf?msafed=0
      Login attempt at Office 365 signin page
      Found sign in elements type 1 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 selected using normal element
      Retrieved user password from cache \\XXXXXXX\profilestore\username\AppData\OneDriveMapper.tmp
      We attempted to login without using ADFS, but did not end up at the expected location. Detected url: https://
    • We had hte same problem with this, we download the latest version v3.10 and it fix our issue
  • OneDrive Mapping Error
    1 Posts | Last post August 04, 2017
    • Great script, but in the last week it has stopped working. I downloaded version 3.10 today and am testing it out, but still getting connection error while trying to connect. 
  • AzureAADConnect SSO Error 224
    3 Posts | Last post August 02, 2017
    • First off, thanks for creating such an awesome tool.
      We are getting the following logs when trying to use v3.09
      08/02/2017 12:39:55 | INFO | -----08/02/2017 12:39:55 OneDriveMapper v3.09 - jerry on RTP34 starting-----
      08/02/2017 12:39:55 | INFO | Script elevation level: User
      08/02/2017 12:39:55 | INFO | Set TLS protocol version to 1.2
      08/02/2017 12:39:55 | INFO | You are S-1-5-21-1960408961-746137067-839522115-4651 running on Windows 6 with IE 11 and Powershell version 3
      08/02/2017 12:39:56 | INFO | NOTICE: you are running the latest (v3.09) version of OnedriveMapper
      08/02/2017 12:39:56 | INFO | Loading CookieSetter...
      08/02/2017 12:39:56 | INFO | Test cookie set successfully
      08/02/2017 12:39:56 | INFO | 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
      08/02/2017 12:39:56 | INFO | NOTICE: mrwpca1-my.sharepoint.com found in IE Trusted Sites on user level
      08/02/2017 12:39:56 | INFO | NOTICE: mrwpca1.sharepoint.com found in IE Trusted Sites on user level
      08/02/2017 12:39:56 | INFO | IE Automatic Proxy Detection is not yet disabled, attempting to disable...
      08/02/2017 12:39:56 | INFO | IE Automatic Proxy Detection disabled
      08/02/2017 12:39:56 | INFO | userLookupMode is set to 1 -> checking Active Directory UPN
      08/02/2017 12:39:56 | INFO | Login for caching supplied, not querying user for login
      08/02/2017 12:39:57 | INFO | Stored user's new login to user login cache file 
    • 08/02/2017 12:39:57 | ERROR | ERROR: WebDav File Locking support is enabled, this could cause files to become locked in your OneDrive or Sharepoint site
      08/02/2017 12:39:57 | WARNING | Maximum file upload size is set to 48 MB
      08/02/2017 12:39:57 | INFO | Not mapping O4B because dontMapO4B is set to True
      08/02/2017 12:39:57 | INFO | Adding to mapping list: Q: (\\mrwpca1.sharepoint.com@SSL\DavWWWRoot\sites\rtp-est\Shared Documents)
      08/02/2017 12:39:57 | INFO | Q: is not yet mapped
      08/02/2017 12:39:57 | INFO | Base URL: https://mrwpca1.sharepoint.com 
      
      08/02/2017 12:39:57 | INFO | Login attempt using native method at tenant mrwpca1
      08/02/2017 12:39:57 | INFO | Received API response for authentication method: Managed
      08/02/2017 12:39:57 | INFO | Additionally, Azure AD SSO and/or PassThrough is enabled for your tenant
      08/02/2017 12:39:57 | INFO | Authentication target: https://autologon.microsoftazuread-sso.com/mrwpca.com/winauth/sso?desktopsso=true&isAdalRequest=False&client-request-id=4391a604-f864-4630-ac8b-a049f8214f4e
      08/02/2017 12:39:57 | INFO | Azure AD SSO response received: AQABAAAAAAA9kTklhVy7SJTGAzR-p1BcTBO_EmJ7jPXcq0pPYO0chPPG3g8-Uq5bPUQE6AIN3mndVNu2e5T73t19AZWMILDCl_MVmuVFgmV3rSmDBRjlTE6lJyjBV0jfQ4CeJrONd2e8PLSzirbJRdGPLQDxnNr6o1YloGxq6_BWsU2vtA4jNvzLfXWGihMR96ZnTH4Lz54c36wbTxweR_3aIfI3udxTDROH7Iz3VPi264ddK0XSx2Yz8z8lQ1xwWnS_JcL3Vf8IPNE3OujTQsiAikgUwLjWSHfS-diN-kCWb3B2-HLSwdQxfZ0VLMVTTV8Dv9LDv7sgAA
      08/02/2017 12:39:57 | INFO | AADC SSO step 1 completed
      08/02/2017 12:39:57 | INFO | Requesting session...
      08/02/2017 12:39:57 | INFO | Checking if we've been Signed in automatically by Azure AD PassThrough...
      08/02/2017 12:39:57 | WARNING | We do not seem to have been properly redirected for SSO yet
      08/02/2017 12:39:57 | INFO | New sts request retrieved
      08/02/2017 12:39:57 | INFO | New flowToken retrieved
      08/02/2017 12:39:57 | INFO | New canary retrieved
      08/02/2017 12:39:57 | INFO | New apiCanary retrieved
      08/02/2017 12:39:58 | INFO | AADC SSO step 2 completed
      
    • 08/02/2017 12:39:58 | INFO | Checking if we've been Signed in by Azure AD
      08/02/2017 12:39:58 | WARNING | We do not seem to have been properly redirected for SSO yet
      08/02/2017 12:39:58 | ERROR | We do not seem to have been properly redirected after signing in.
      08/02/2017 12:39:58 | INFO | Initiating session with: https://mrwpca1.sharepoint.com/sites/rtp%2Dest/Shared%20Documents
      08/02/2017 12:39:58 | INFO | Retrieving Sharepoint cookie step 1...
      08/02/2017 12:39:59 | ERROR | Problem reported during step 2: no next url detected: -1
      08/02/2017 12:40:01 | INFO | SpO cookie generated, attempting to map drive
      08/02/2017 12:40:01 | INFO | Mapping target: \\mrwpca1.sharepoint.com@SSL\DavWWWRoot\sites\rtp-est\Shared Documents
      08/02/2017 12:40:02 | ERROR | ERROR: detected string error 224 in return code of net use command, this usually means your trusted sites are misconfigured or KB2846960 is missing
      08/02/2017 12:40:02 | ERROR | failed to contact Q: after mapping it to \\mrwpca1.sharepoint.com@SSL\DavWWWRoot\sites\rtp-est\Shared Documents, check if the URL is valid. Error: 
       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.
       
      
      08/02/2017 12:40:02 | INFO | OnedriveMapper has finished running
      08/02/2017 12:40:02 | WARNING | restartExplorer is set to False, if you're redirecting My Documents, it won't show until next logon
      
      We have AzureADConnect SSO running, so basically the user's email address is automatically populated in the O365 form, and if you tab down to the password field it logs in.
      
      Is there a way to avoid this 'Error 224' or is this type of SSO not supported?
      Thanks,
      Russell
  • cant map drive
    2 Posts | Last post July 20, 2017
    • Hi Jos 
      
      I need help
      I running a script and receive 
      
      ERROR | We do not seem to have been properly redirected after signing in.
      ERROR | fallback mode is enabled, and login failed. Attempting IE auth mode.
      
      at end of running script pop up error:
      Mapping cannot continue because we cannot detect your username 
    • download the latest version from my blog, it was fixed in v3.09 after a change by MS
  • OneDriveMapper not working with RMUnify
    2 Posts | Last post July 14, 2017
    • Hi Jos,
      
      I'm trying to get this script working with RMUnify, but am getting exactly the same error message as one of the other users here:
      
      It throws the errors:
      
      Exception calling "Substring" with "2" argument(s): "Length cannot be less than zero.
      Parameter name: length"
      
      Method invocation failed because [System.Int32] does not contain a method named 'IndexOf'.
      
      Exception calling "Create" with "1" argument(s): "Invalid URI: The format of the URI could not be 
      determined."
      
      From your notes in the script I can see that you have support for RMUnify so are you able to offer any further advice?
      
      Many thanks in advance,
      
      Phil
    • Last time I did anything around RMUnify, it was in IE auth mode, native auth mode won't work with RMUnify until I do dev on it, which I most likely won't as I don't have RMUnify :)
  • WebDAV Space Reporting
    4 Posts | Last post June 28, 2017
    • Hello.
      
      First, thank you for this excellent script.
      
      Second, Question - the known WebDAV issue (by design) about not reporting the true space available and instead mirroring the space on the System drive - does this actually limit the amount of storage available, or would the full amount of space (In the case of OFB - 1 TB) be available?
      
      Thanks
      
      Ed
    • Its all available :)
    • Thanks!
      
      Ed
    • hi, it seems that it is not like this. I mean if it shows that you have 4 GB free based on your drive C, you really have only 4GB. I just checked it. Am I doing something wrong?
  • Can't run from shortcut
    1 Posts | Last post June 23, 2017
    • Great script that works when I run it manually, but I'm trying to get it to run from a shortcut and all I get is a quick flash of the command prompt and then nothing.
      
      Shortcut target is:
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy ByPass -File “C:\Program Files (x86)\OneDriveMapper\OneDriveMapper_v1.ps1”
      
      I tried using %SystemRoot% instead of C:\Windows but it doesn't make a difference.
      
      I even set the execution policy to unrestricted but it didn't help.
      
      Thanks in advance for any guidance!
  • Hi Jois
    1 Posts | Last post June 22, 2017
    • Thanks for script. It works as expected for mapping OneDrive for some users but it fails on certain users . Please find below the error log.Will you be able to help me here. Note i have changed my company and user details.
      
        | INFO | IE login function succeeded
        | INFO | Attempting to detect username at https://login.microsoftonline.com/a00452fd-8469-409e-91a8-bb7a008e2da0/oauth2/authorize?client_id=00000003-0000-0ff1-ce00-000000000000&response_mode=form_post&response_type=code%20id_token&resource=00000003-0000-0ff1-ce00-000000000000&scope=openid&nonce=39FFAFC9006DAE89E9D4F6DE415B41C683ADD5F4046EA6F5-31FB34D7250943AF75C742CE81E4E19335AF193080E0A6BEB75B0A52278A85EF&redirect_uri=https:%2F%2Fmycompany-my.sharepoint.com%2F_forms%2Fdefault.aspx&state=0&client-request-id=4f37fe9d-a0c4-3000-2b48-8e38666820cf, waited for 0 seconds
      06/22/2017 14:29:53 | INFO | Attempting to detect username at https://login.microsoftonline.com/a00452fd-8469-409e-91a8-bb7a008e2da0/oauth2/authorize?client_id=00000003-0000-0ff1-ce00-000000000000&response_mode=form_post&response_type=code%20id_token&resource=00000003-0000-0ff1-ce00-000000000000&scope=openid&nonce=2BCA775A62805468A2A10132044727F13EE639EF1AF5BBA6-179FED0F25BFFCD24CF153731FCAAE83A3C71716E9A972F4C3EA4B5DA07F4A1D&redirect_uri=https:%2F%2Fmycompany-my.sharepoint.com%2F_forms%2Fdefault.aspx&state=0&client-request-id=5137fe9d-30a0-3000-2b48-89be96f55459, waited for 2 seconds
      
      
      
61 - 70 of 192 Items