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)
75,573 times
Add to favorites
Office 365
2/3/2019
E-mail Twitter del.icio.us Digg Facebook
  • How to avoid password prompt
    6 Posts | Last post March 22, 2017
    • We are using Azure AD Connect to synchronize AD accounts to Office 365. This is for use in a computer lab at a school. The user profile gets wiped at logoff. I am trying to use your wonderful script, but I get a password prompt every time.  Is there a way to avoid the password prompt, or do I have to wait until we move to ADFS?
    • Hi,
      
      Well, I guess two options. Office 365 can only do integrated authentication if you have STS (like ADFS), or if you use AzureAD PassThrough. The latter is not yet supported as Microsoft hasn't been very forthcoming in helping me there.
      
      ADFS gives you single signon, and thus no need for a password.
      
      Until you have ADFS, the script really needs the user's password. Normally, it caches that in %APPDATA%, if you choose a different location that doesn't get wiped (homedrive for example), the script wouldn't have to keep prompting (unless the password was changed). The cache location can be configured in the script's configuration section.
    • Ok. It looks like I will have to convince our network engineer to go to ADFS for this. 
      
      Thank you very much for taking the time to answer, and for answering so quickly.
    • Interesting concept to add password file to home drive,we are using this but the issue we have is anytime the users accesses a different workstation it still prompts as it state password file is not valid !!
      
      so I am assuming we will need to wait till AzureAD passthrough is working ?
      
      
    • Hmm, the password file is encrypted using a local encryption secret, this means it can only be accessed from the same workstation I'm afraid.
    • Any chance of adding the option for clear password, so then this would work?
  • change the script to "sign in persistence"?
    6 Posts | Last post March 19, 2017
    • HI Jos
      I have mapping failure, during the ps run I saw following message:
      
      "Detected an url that indicates we've been signed in automatically: https://xxx-my.sharepoint.com/personal/user_domain_com/_layouts/15/onedrive.aspx, but we did not select sign in persistence, this may cause an error when mapping"
      
      How can we change the script to "sign in persistence"?
      
      Thanks
    • Is it mapping correctly, or not? Did you do the userlookupmode change I suggested earlier?
    • 1. the mapping is correct
      
      2. yes I change the userlookupmode as you suggest (-eq instead of -le)
    • so there is no issue then ;)
    • sorry but I misguide you
      
      first I receive following:
      ERROR | Detected an url that indicates we've been signed in automatically: https://xxx-my.sharepoint.com/personal/user_domain _com/_layouts/15/onedrive.aspx, but we did not select sign in persistence, this may cause an error when mapping.
      
      than I receive: 
      INFO | Mapping target:\\xxx-my.sharepoint.com@SSL\DavWWWRoot\personal\user_domain_com\Documents
      ERROR: detected string error 224 in return code of net use command, this usually means your trusted sites are misconfigured or KB2846960 is missing
      ERROR | failed to contact O: after mapping it to \\xxx-my.sharepoint.com@SSL\DavWWWRoot\personal\user_domain_com\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.
      BTW the trusted site is properly configured
    • Please take this to my blog, my contact info is there and I'd need the full log
  • Onedrive for business on-prem
    2 Posts | Last post March 19, 2017
    • Hey
      
      Does it work on on-prem? (Onedrive for business)?
      
      Thanks in advance
      
      Mike
    • Hi Mike,
      
      not out of the box, it was designed for office 365, but it can certainly be modified for onprem.
  • Upload Limit 48Mb
    2 Posts | Last post March 05, 2017
    • Jos, this seems to be a default - does that come from SharePoint Online?
      Where can I increase this please?
      
      Greatly appreciate your script... it is awesome!
    • That's a Windows built in default, here's a KB that helps: https://support.microsoft.com/en-us/help/900900/folder-copy-error-message-when-downloading-a-file-that-is-larger-than-50000000-bytes-from-a-web-folder
  • Mapping cannot continue because we could not log in to office365
    1 Posts | Last post March 02, 2017
    • Hi Jos,
      I do the change but still same error:
      ERROR | For some reason we're not at the logon page, even though we tried to browse there, we'll probably fail now but let's try one final time.
      URL: https://eci365-my.sharepoint.com/personal/yweinre_ecitele_com/_layouts/15/onedrive.aspx
      INFO | Detected running explorer process
      INFO | Login attempt at Office 365 signin page
      INFO | Failed to find signin element type 1 on Office 365 login page, trying next method. Error details: Exception from HRESULT: 0x800A01B6
      INFO | Failed to find signin element type 2 on Office 365 login page, trying next method. Error details: Exception from HRESULT: 0x800A01B6
      ERROR | Failed to find signin element type 3 at https://login.microsoftonline.com/login.srf. You may have to upgrade to a later Powershell versio
      n or Install Office. Attempting to log in anyway, this will likely fail. Error details: Exception from HRESULT: 0x800A01B6
      INFO | attempting to trigger a redirect to SSO Provider using method 1
      ERROR | Failed to find the correct controls at https://eci365-my.sharepoint.com/personal/yweinre_ecitele_com/_layouts/15/onedrive.aspx to log in
      by script, check your browser and proxy settings or check for an update of this script. Exception from HRESULT: 0x800A01B6
      INFO | autoProtectedMode is set to True, reverting to old settings
      INFO | Setting zone 0 back to 3
      INFO | Setting zone 1 back to 3
      INFO | Setting zone 2 back to 3
      INFO | Setting zone 3 back to 0
      INFO | Setting zone 4 back to 0
      INFO | Automatically added aadg.windows.net.nsatc.net to intranet sites for this user
      INFO | Automatically added autologon.microsoftazuread-sso.com to intranet sites for this user
      INFO | OnedriveMapper has finished running
      WARNING | restartExplorer is set to False, if you're redirecting My Documents, it won't show until next logon
      Thanks
  • Mapping cannot continue because we could not log in to office365
    2 Posts | Last post March 02, 2017
    • Hi Jos,
      
      we are using a third party samlproxy in our adfs "O365" Relying party trusts.
      we receive error message "Mapping cannot continue because we could not log in to office365"
      on powershell we receive following:
      ERROR | For some reason we're not at the logon page, even though we tried to browse there, we'll probably fail now but let's try one final time. URL: https://login.microsoftonline.com/login.srf
      INFO | Detected running explorer process
      INFO | Login attempt at Office 365 signin page
      ERROR | failed to use Azure AD SSO for Workplace Joined devices
      INFO | Failed to find signin element type 1 on Office 365 login page, trying next method. Error details: Could not complete the operation due to error 80700009.
      INFO | Failed to find signin element type 2 on Office 365 login page, trying next method. Error details: Could not complete the operation due to error 80700009.
      ERROR | Failed to find signin element type 3 at https://login.microsoftonline.com/login.srf. You may have to upgrade to a later Powershell version or Install Office. Attempting to log in anyway, this will likely fail. Error details: Could not complete the operation due to error 80700009.
      INFO | attempting to trigger a redirect to SSO Provider using method 1
      ERROR | Failed to find the correct controls at https://xxx-my.sharepoint.com/personal/yyy_domain_com/_layouts/15/onedrive.aspx to log in by script, check your browser and proxy settings or check for an update of this script. Exception from HRESULT: 0x800A01B6
      INFO | autoProtectedMode is set to True, reverting to old settings
      INFO | Setting zone 0 back to 3
      INFO | Setting zone 1 back to 3
      INFO | Setting zone 2 back to 3
      INFO | Setting zone 3 back to 0
      INFO | Setting zone 4 back to 0
      INFO | Automatically added aadg.windows.net.nsatc.net to intranet sites for this user
      INFO | Automatically added autologon.microsoftazuread-sso.com to intranet sites for this user
      INFO | OnedriveMapper has finished running
       
    • Change this line: 
      
      if($userLookupMode -le 3){
      
      to 
      
      if($userLookupMode -eq 3){
  • One drive mapper will close the internet explorer
    2 Posts | Last post March 01, 2017
    • one drive will close the internet explorer and also will check for the later version
      can we disable these two item?
    • of course, version check is fully optional, closing internet explorer prevents certain issues, but you can try and see if it works for you.
  • Sharepoint http load when finished
    7 Posts | Last post February 28, 2017
    • Hi Jos,
      
      Would it be possible to log into and display Sharepoint through the default web browser as the last action in the script?
    • You could use the urlopenafter parameter, that would use IE though, but the code to use another browser would be super easy to do.
      
      If you use another browser, the script won't have logged in for you.
    • Hi Jos,
      
      Thanks for replying. Unfortunately while I can add the url to our Sharepoint page, it still asks the user to sign in to their account, even in IE.
    • Is the URL you're opening an URL you're mapping? A cookie does have to be present, the script only sets cookies for URLs you map.
      
      Otherwise you might need some custom coding, I know it is theoretically possible to inject cookies into chrome and Firefox too.
    • Hi Jos,
      
      Lets say our domain is company.com and the sharepoint site is companygroup.sharepoint.com.
      
      Please find current settings below:
      
      $configurationID       = "00000000-0000-0000-0000-000000000000" 
      $domain                = "company.com"
      $driveLetter           = "O:"
      $redirectMyDocs        = $False
      $redirectMyDocsName    = "Documents"
      $driveLabel            = "OneDrive"
      $O365CustomerName      = "companygroup"
      $logfile               = ($env:APPDATA + "\OneDriveMapper_$version.log")
      $pwdCache              = ($env:APPDATA + "\OneDriveMapper.tmp")
      $loginCache            = ($env:APPDATA + "\OneDriveMapper.tmp2")
      $dontMapO4B            = $False
      $debugmode             = $False
      $userLookupMode        = 1 
      $AzureAADConnectSSO    = $True
      $lookupUserGroups      = $False
      $forceUserName         = ''
      $forcePassword         = ''
      $restartExplorer       = $False
      $autoProtectedMode     = $True 
      $adfsWaitTime          = 0
      $libraryName           = "Documents"
      $autoKillIE            = $True
      $abortIfNoAdfs         = $False
      $adfsMode              = 1
      $displayErrors         = $True
      $buttonText            = "Login"
      $adfsLoginInput        = "userNameInput"
      $adfsPwdInput          = "passwordInput"
      $adfsButton            = "submitButton"
      $urlOpenAfter          = "https://companygroup.sharepoint.com/SitePages/Home.aspx"
      $showConsoleOutput     = $False
      $showElevatedConsole   = $True
      $sharepointMappings    = @()
      $sharepointMappings    += "https://companygroup.sharepoint.com/SitePages/Home.aspx"
      $showProgressBar       = $True
      $versionCheck          = $True 
      
      I've removed mapping Sharepoint to a drive as we don't want users having explorer access to it. I've added the sharepoint url itself back in to that field (sans a drive letter) just to see if this would make a difference to being automatically signed in IE. Unfortunately that didn't help either.
    • Yeah that wouldn't do much, because the script normally only signs you in to URL's that you defined to map, the URLOpenAfter parameter was added for a consultancy customer who had a GPO that automaticallly opens sharepoint for their employees. When they deployed OnedriveMapper, that GPO had to be disabled, or Onedrivemapper would kill IE. So, what you're asking could be done, but it would require changes to the script.
    • Thanks for the response Jos. If you accept idea suggestions then I would definitely submit this as one but otherwise thanks for this clever script, it's working perfectly in our organisation.
  • Better /persistent:no ?
    2 Posts | Last post February 28, 2017
    • Hi Jos,
      
      I just rolled this out to a few small business customers... I found that since the mapping does not last forever and you need to re-map (I have put into startup), it makes more sense to map persistent:no to avoid having an old (broken) mapping.
      I changed this in the code... and it now works fine, but would it not be better to have as the default or at least have as a parameter?
      
      Regards, Andrew
    • Hi Andrew,
      
      I guess that could be a matter of preference, as the script takes a little while, some would prefer if most of the time it'd still be mapped. But I guess I can add a parameter so it is easier to choose between both options.
  • Failed to Load Signin Element Type 1
    3 Posts | Last post February 23, 2017
    • Hi Jos,
      
      I have an issue at the moment where I receive:
      
      "INFO | Detected running explorer process
      INFO | Login attempt at Office 365 signin page
      INFO | Failed to find signin element type 1 on Office 365 login page, trying next method. Error details: Method invocati
      on failed because [System.__ComObject] does not contain a method named 'IHTMLDocument3_getElementById'.
      INFO | Failed to find signin element type 2 on Office 365 login page, trying next method. Error details: Method invocati
      on failed because [System.__ComObject] does not contain a method named 'IHTMLDocument3_getElementById'."
      
      I'm running this on a server as I need to map our SharePoint library (hosted on Office 365) to the local S Drive. As such, I don't have Office installed. Is there any way of getting this working on a server? 
      
      Regards,
      
      Rob
    • Hi Rob,
      
      you could try replacing all instances of IHTMLDocument3_getElementById with getElementById, the older function that is pre-office.
      
      Or wait till the next version, it'll have a totally IE free auth setting.
    • Thanks, Jos! Very much appreciated :) 
101 - 110 of 197 Items