Posted on 02-07-2019 05:19 AM
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?
Posted on 02-07-2019 08:57 AM
@kericson May be able to help you out here.
Posted on 02-07-2019 10:08 AM
@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.
Posted on 02-07-2019 11:13 AM
@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.
Posted on 02-07-2019 12:40 PM
@kericson I would be very interested in that script!
Posted on 02-07-2019 01:06 PM
Heres the script: Script
Posted on 02-08-2019 10:42 AM
@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.
Posted on 02-08-2019 12:25 PM
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.
Posted on 06-26-2019 08:38 AM
@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?
Posted on 06-26-2019 11:01 AM
@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.
Posted on 06-26-2019 02:06 PM
@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?
Posted on 06-27-2019 05:31 AM
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
Posted on 06-27-2019 06:34 AM
@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.
Posted on 12-02-2019 12:13 PM
@kericson Do you know if that Known Folders Redirect script works on 10.15?
Posted on 12-02-2019 08:19 PM
@McAwesome I haven't tested this on 10.15, I assume it works.
Posted on 02-18-2020 11:39 AM
@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
Posted on 05-13-2020 01:43 PM
the script is working on 10.15 however i had to approve OneDrive's disk/folder access
Posted on 05-14-2020 06:56 AM
Posted on 05-20-2020 06:56 AM
@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.
Posted on 06-12-2020 10:45 AM
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?
Posted on 06-12-2020 11:33 AM
@strayer It's been previously reported that enabling iCloud Drive will reset the symlinks on restart
Posted on 06-15-2020 05:17 AM
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
Posted on 07-29-2020 10:25 PM
@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.