When your company is migrating to Office 365, there will be a time where your users no longer have a need for personal home drives in the form of a traditional network share. Maybe you also have roaming profiles that you no longer need.
Local storage is generally not needed if your users have a fair amount of assigned storage in their Onedrive. A user’s Onedrive can easily replace the home drive and profile directory. Onedrive will work seamlessly across multiple devices, just like a roaming profile would. On the other hand, local server storage is expensive and generally not available from outside the company unless a VPN is in place. All in all, Onedrive could very well be a worthy replacement.
If you want to get some ideas on how to copy all the users’ data, you can find a walkthrough from LazyAdmin here that copies data from a mapped home drive to the Onedrive location where the Onedrive sync process will pick the files up and sync them to the online storage.
Alternatively, you could look into copying the data serverside.
At one point you have copied the users’ data to Onedrive and you want to mass update the local AD accounts and remove the home drive and profile mappings.
This is a great example of where Powershell can do work in seconds where manual clicking takes hours.
AD attributes
The home drive and profile settings are stored as part of the User object in Active Directory. The following attributes hold this information:
- HomeDirectory – The local or Universal Naming Convention (UNC) path to the home directory for the user.
- HomeDrive – The driveletter assigned to the homedirectory. The value must be a single, uppercase letter and a colon (:) is required.
- ProfilePath – This value can be a local path or a Universal Naming Convention (UNC) path.
Clearing the HomeDirectory and ProfilePath
The following Powershell script will fetch all users in a specific OU and will remove whatever is set for the attributes HomeDirectory, HomeDrive, and ProfilePath. I’ve deliberately written it in a way that it is easy to follow. The account that runs the script, needs to have the proper access to write to user objects.
# We need to do AD related actions
Import-Module ActiveDirectory
# Example: "OU=Accounts,OU=Managed,DC=froqr,DC=com"
$OU = <fill in your OU where the userobjects are stored>
$users = Get-ADUser -SearchBase $OU -Filter *
foreach ($user in $users){
Set-ADUser -Identity $user -Clear HomeDirectory,HomeDrive, ProfilePath
}
One interesting thing to point out is that I use the -Clear function to remove all content from the respective fields. This because I do not want to have a blank value in those fields, I want it to be actually empty without any value.