It might be as simple as this:
Get-MailUser -ResultSize Unlimited |
if ($_.ExtensionAttribute2){
$mgr = $_.ExtensionAttribute2
$_ | Set-User -Manager $mgr
}
You don't say how the manager is represented in ExtensionAttribute2, though. If the value isn't acceptable for use in the Set-User cmdlet you might have to locate the manger's user (or contact) object in the AD and use, say, its distinguishedName instead of the value found in ExtensionAttribute2.