Update Profile Path for filtered users

$users = Get-aduser -filter 'profilepath -like "*oldservername*"'
foreach ($user in $users) {
# The line below returns the profilepath as a STRING with no headers
$profilepath = get-aduser $user -properties profilepath | foreach {$_.ProfilePath}
$newprofilepath = $profilepath -replace "oldservername", "domain.local\Data"
set-aduser $user -profilepath $newprofilepath
}