I created this script because of moving the profiles to a server in the data center were also the terminal server is located.

Powershell needs to be runned as Administrator

########
## created by Daag van der Meer
## blog.van-daag.nl
## 26-04-2018
########
#
# Script is used to set Homedrive, RDP Homedrive, Profilepath, RDP profile path.
#
# Script needs to be runned as Admin!!!


Import-Module ActiveDirectory
     # On the Domain Controller There is on C:\Temp\Users.txt with the usernames to change the path

foreach ($user in (get-content c:\temp\Users.txt)) {
    ## Homedrive and profile location
    $homeDirectory = '\\<NewServer>\home$\<Country>\' + $user; 
    $ProfilePath = '\\<NewServer>\Profile$\<Country>\' + $user; 

    ## Set homedrive (DISABLE THIS IF YOU DON'T WANT TO CHANGE THIS)
    # Finally set their home directory and home drive letter in Active Directory
    Set-ADUser -Identity $user -HomeDirectory $homeDirectory -HomeDrive H
	
	## Set Profile (DISABLE THIS IF YOU DON'T WANT TO CHANGE THIS)
		Set-ADUser -Identity $user -ProfilePath $ProfilePath
        
        ## Set RDP Profile and Homedrive
        Get-ADUser -Filter "SAMAccountName -like '$user*'"| ForEach-Object {
        $ADSI = [ADSI]('LDAP://{0}' -f $_.DistinguishedName)
        try {
            $ADSI.InvokeSet('TerminalServicesProfilePath',$ProfilePath)
            $ADSI.InvokeSet("TerminalServicesHomeDrive","H:")
            $ADSI.InvokeSet("TerminalServicesHomeDirectory",$homeDirectory)
            $ADSI.SetInfo()
        }
        catch {
            Write-Error $Error[0]
        }
}
	
}