OneDrive as home folder location

AVmcclint
Honored Contributor

We are in the very early stages of implementing the full M365 solution at my workplace and the Windows engineers mentioned something that worried me as the Mac admin. They said the plan was to have every user's network home folder as defined in AD to be the OneDrive location. Not just a defined folder within, but the whole thing. I know on the Mac when an AD user logs in for the very first time (as a Mobile User), the network home path needs to be a valid path with the correct permissions etc or else the Mobile User account will not be created and they won't be able to login. Has anyone set the network home folder path in AD to point to their cloud location?

  • If so, how does it work with new users behind firewalls and proxies upon first login?
  • How did you migrate existing users?
  • When you click on the globe icon in the dock, what does it mount? and how is that different from using the OneDrive app?
22 REPLIES 22

rdalton
New Contributor

@kericson May be able to help you out here.

woodsb
Contributor

@AVmcclint,

As far as I know, the home folder nor any of its contents can be moved to the OneDrive Folder. This stopped working when Apple depreciated hard links in macOS. You can only create aliases (shortcuts) in OneDrive at the moment.

KyleEricson
Valued Contributor II

@AVmcclint I have a script that redirects users home folders. The folders move to OneDrive with links back. Folders I move are:
Desktop, Documents, Pictures, Movies, and Music. Let me know if you want the script.

Read My Blog: https://www.ericsontech.com

mark_mahabir
Valued Contributor

@kericson I would be very interested in that script!

KyleEricson
Valued Contributor II

Heres the script: Script

Read My Blog: https://www.ericsontech.com

AVmcclint
Honored Contributor

@kericson Just to make sure I understand the flow of your script...

It looks for /Users/jsmith/OneDrive - MyCompany/
then appends "-old" to any existing standard user subfolders in /Users/jsmith/OneDrive - MyCompany/ so the result would be:
/Users/jsmith/OneDrive - MyCompany/Movies-old
/Users/jsmith/OneDrive - MyCompany/Documents-old
and so on...
Then it moves /Users/jsmith/Documents/ (etc) to /Users/jsmith/OneDrive - MyCompany/Documents/
Then makes symlinks within /Users/jsmith/ that point all the user subfolders to /Users/jsmith/OneDrive - MyCompany/
Then it deletes all the "-old" folders if they exist

If that's an accurate simplification of what it does, I think I get it. it still sounds scary to redirect the user subfolders like that. I've never had good results doing that in the past. There was always SOMETHING that didn't play well redirected folders. I notice that you don't redirect Library or any loose files located within ~/ I presume that's on purpose?
One of my main questions is when you login as an AD user for the very first time with the home folder path pointing to OneDrive, are there any issues with Mobile Account creation? I also presume that since the subfolders still reside locally on the hard drive, there's no issues with users being not being connected to the internet? Pardon my complete ignorance on this. Our Office365 project is going to be massive and I am a complete O365 n00b.

KyleEricson
Valued Contributor II

No problem yeah you have the general idea. The old folders get moved to their new location. Example Documents-old gets copied to Documents once the link has been setup. Mobile accounts should have no issues I have tested both. Just make sure you don’t use the files on demand feature on the parent folder. So don’t do it on the standard users folders; Desktop, Documents, and etc. I don’t move library and single files on purpose this could be really bad. Hope that clears things it up.

Read My Blog: https://www.ericsontech.com

JMenacker
New Contributor III

@kericson this looks fantastic. Just curious what happens when a user is unable to access the network. Will the changes sync automatically when they regain network connection? Also, since Desktop is the first thing they see when logging in will this mess anything up if it's unable to connect for whatever reason?

KyleEricson
Valued Contributor II

@JMenacker I have never had an issue when I don't have a network or even when my token expires from OneDrive. Yes once connected back to network everything should sync back up. I have also never seen a issue with the desktop and files.

Read My Blog: https://www.ericsontech.com

JMenacker
New Contributor III

@kericson that's great, thank you. Is there a way to revert back if they decide not to utilize sync anymore? Also, what if we get a new computer and sign in? Will it automatically sync from the Home folders up to OneDrive and delete whatever is in the existing folders with those same names?

KyleEricson
Valued Contributor II

This is what I use to remove. I just run this script from self-service on new Macs.
Script

#!/bin/sh

#!/bin/bash
#Created by Kyle Ericson
#Version 1.0


#Get the current user
currentUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");')

#OneDrive Location
oneDriveDirectory="/Users/$currentUser/OneDrive - Ace Manufacturing"

if [[ ! -d $oneDriveDirectory ]]
then
    echo "Folder not found. You need to set up OneDrive first, then run again"
    exit 1
fi


for dir_to_link1 in Desktop Documents Movies Pictures Music
do
    unlink /Users/$currentUser/$dir_to_link1
done


for dir_to_link1 in Desktop Documents Movies Pictures Music
do
    sudo mv "$oneDriveDirectory/$dir_to_link1" "/Users/$currentUser/"
done

echo "Success all folders have been removed from OneDrive Peace Brother!"

exit 0
Read My Blog: https://www.ericsontech.com

JMenacker
New Contributor III

@kericson so this script just removes the links to OneDrive but doesn't put the Home folders back? Seems half baked but I like the idea of automating in general. Needs some love though to make it production for any business environment for sure. Thanks for sharing.

McAwesome
Valued Contributor

@kericson Do you know if that Known Folders Redirect script works on 10.15?

KyleEricson
Valued Contributor II

@McAwesome I haven't tested this on 10.15, I assume it works.

Read My Blog: https://www.ericsontech.com

AdamCraig
Contributor III

@kerickson I've used both your Redirect and Unlink folders successfully on 10.15 with a testing laptop, my laptop and a few other machines. We're going to test the redirection for a little bit before we make it available to standard users but everything seems to be great! Thanks

McGinn
Contributor

the script is working on 10.15 however i had to approve OneDrive's disk/folder access

KyleEricson
Valued Contributor II

I have a new updated version see my github. @McGinn

Read My Blog: https://www.ericsontech.com

AdamCraig
Contributor III

@kerickson Running it locally to test it out and the fix filenames script isn't fixing a folder of characters with lots of the ineligible characters in the name. Your setup folders script works great for me

Edit - I found the error. So I had other files in my onedrive with "OneDrive" in the name. such as a plist and a folder of screenshots I'd made to document instructions "OneDrive setup screenshots" that made it so the $onedrive variable was a list of locations rather than just the one location. and none of the other commands were searching correctly. I changed the find command to just look for the folder named OneDrive - MyCompanyName in the default location.

AdamCraig
Contributor III

Anyone else having issues where OneDrive Folder Redirection and Catalina and iCloud Drive (not documents and desktop, just icloud drive) undoes the folder redirection upon rebooting the computer?

sdagley
Esteemed Contributor II

@strayer It's been previously reported that enabling iCloud Drive will reset the symlinks on restart

jburgod
New Contributor

I have only a couple Macs so rather than deal with the script, I just ran the commands to redirect the Desktop, Documents & Downloads. The linking process appears to complete without error, but it doesn't function as expected. For example, items copied or saved to the Desktop symolic link appear in the OneDrive folder, but don't appear on the Mac desktop. Also, the Desktop and Documents redirect / link does not persist through a reboot. Has anyone else experienced these issues or have a resolution?

macOS 10.15.5

SteveC
New Contributor III

@jburgod It's working OK for me in test manually linking individual folders on 10.15.6. It doesn't seem to play nicely with files on demand, and if you have iCloud Drive enabled that messes it up too.