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)
74,794 times
Add to favorites
Office 365
2/3/2019
E-mail Twitter del.icio.us Digg Facebook
  • Script Successful, Mapped Drive not Visible
    2 Posts | Last post January 28, 2016
    • Hi there,
      
      Firstly thanks for this script looks incredibly useful however I am running into some issues on Windows 7.
      
      The script says it has completed successfully with no errors, however the drive does not show up. There is also no drive letter in HKCU\Network. Any ideas on what might be causing this?
      
      Any help greatfully received.
      
      TM
    • is it visible in an elevated prompt? Did you run the script UNelevated? 
      
      And running v2.25?
  • Mail merge
    2 Posts | Last post January 23, 2016
    • hi there do you know if this will allow mailmerge with a /xls data source stored on sharepoint? at present this isnt supported with office 2013 and SP Online
      thanks
      joe
    • No, I'm afraid Office seems to realize that it is actually a HTTPS connection and throws an error. There are some workarounds, but I'd recommend converting the XLS to a Sharepoint List.
  • Username not found
    5 Posts | Last post January 21, 2016
    • Hi, im really excited about this excellent script but have unfortunately not yet managed to get it to work.
      
      I think we have a fairly standard O365 setup with the UPN matching between on premise and the cloud and have ADFS implemented (this i think is "skinned").
      
      I think i have filled in the correct script parameters but the log file is showing username not found at the end.  
      
      Would appreciate any suggestions you may have.
      
      Thanks
      Gareth
    • try running it in debug mode, so you can see what happens. It has to end up at the Onedrive page of the user, from where it will get the proper url to map to.
      
      other than that I'd need a full Problem Step Recording + logfile to help you out...
    • Thanks, i have tried the debug and its does not open the web page correct, just get page cannot be displayed on the https://unimailwinchesterac.onmicrosoft.com-my.sharepoint.com/ URL.
      
      How do i do the problem step recording please?
      
      Thanks v.much
      Gareth
    • I have now realised with the help of a colleague that i had mis-read the instruction of what to put in the $O365CustomerName.  I have now corrected this and the web browser opens correctly to my one drive, however im still not getting the drive mapped.  Please can you clarify what should go in the two $sharepointmappings lines as i have left them unchanged but dont actually want to map any sharepoint libraries and there is definitely an error related to this in the log.  However when i comment either of the lines out i get an error in the powershell window.
      
      thanks
      Gareth
    • The default settings do not map anything to Sharepoint, the 'default' url as configured in the script isn't actually mapped by the script, it is just an example. You can leave it or remove it, but that won't cause an error. Removing the line with $sharepointMappings = @() will of course cause an error.
      
      Without your (full) logs I'm afraid I won't be able to help you much further, I doubt it is related to Sharepoint, make sure you follow the instructions on my blog (linked in the post).
  • Drive mapping works, but I get a strange error...
    3 Posts | Last post January 20, 2016
    • Hi there.
      
      The drive mapping works well for me, but I get a strange error on line 280, character 75:
      
      Exception calling "ReleaseComObject" with "1" argument(s): "Object reference not set to an instance of an object."
      At C:\OneDriveMapper_v2.24.ps1:280 char:75
      +         $Null = [System.Runtime.Interopservices.Marshal]::ReleaseComObject <<<< ($del)
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : DotNetMethodException
      
      Any ideas? 
      
      Thanks 
      
      Stuart
    • Don't worry, that's just cleanup, you can ignore that error. It means the 'clean' quit of the com object worked for you, so the 'thorough' cleanup fails since it was cleaned up :)
    • Awesome - many thanks for the excellent script!
  • URL for OneDrive
    2 Posts | Last post January 12, 2016
    • I tried to map users to their respective OneDrive for Business folder.  I tested the script and "O" drive is mapped to $O365CustomerName-my.sharepoint.com on DavWWWRoot.  What did I do wrong and where do I fix it?  I specified $sharepointURL   as http://contoso-my.sharepoint.com.
      
      Thanks,
      Mark
    • Hello Mark,
      
      The sharepointURL is for mapping to a Sharepoint Library. If you're mapping to Onedrive for Business, you should not configure this setting.
      
      The comments in the script and the manual on my blog should tell you which options to configure with which settings, let me know if I missed anything though!
      
      Jos.
  • Stop if ADFS does not work
    2 Posts | Last post December 23, 2015
    • Hi,
      
      We just found your script while searching for a solution not requiring a 'sync' to access OneDrive and we are really happy about it. There's only a few points that could be enhanced/corrected for it to be perfect.
      
      First, it would be nice to have an option to stop after trying to connect with ADFS. The reason in our case is simply that a user will have a OneDrive associated with his connected upn or simply won't. 
      
      So we don't want a user without OneDrive to be bothered with a password prompt. As a quick workaround for now, we'll simply call "abort_OM" at the start of "askForPassword" and it should do the work nicely.
      
      Secondly, on line 232, you have a typo. "OutNull" should be "Out-Null". Otherwise the line is not executed and explorer is not restarted.
      
      And for the final point, on line 669, that command wrongly assume that this value is absolutely present in the registry. Which is not always the case if the setting never was changed. This causes the script to 'crash' because Protected Mode isn't disabled correctly.
      
      So we replaced that line with this block of script:
      
      $curr = Get-ItemProperty -Path "$($BaseKeypath)\$($i)\" -Name "2500" -ErrorAction SilentlyContinue | select -exp 2500
                        If(!($?)){
                              $curr = 0
                              ac $logfile "Value in zone $i was not created, it will be created to 3 and reverted to 0 afterwards (Default value)"
                        }
      
      				  
      Otherwise, amazing job, that really saved us a lot of time.
      
      Thank you
    • Hello Martin,
      
      thanks for the feedback! I have added the feature and fixed the bugs you mentioned. See v2.23's inline changelog for any other changes.
      
      Jos.
  • Could this be modified for an On-Premise SP?
    2 Posts | Last post December 09, 2015
    • Jos,
      
      I was wondering, could this be modified to be run against and on-premise farm?
      
      Thank you,
      Zack
    • Absolutely :)
      
      It'd take a little code customization but you'll get very good performance, assuming you've got Lan speeds to yours SP farm.
  • 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).
181 - 190 of 197 Items