When decommisioning the home folders in Active Directory, ex. because of Sharepoint / OneDrive migration, you can use this one-liner to remove all the old mappings:
get-aduser -filter{Homedirectory -like ‘*’} -SearchBase ‘OU=Ou,DC=domain,DC=com ‘|Set-ADUser -Clear homedirectory -Verbose
So you come from this:
To This:
Source: [SOLVED] Powershell Removing all home directory mappings (spiceworks.com)