How do I set msExchMailboxGUID using powershell or any other method?

Solution 1:

Continuing from your example, this would work:

$guid = $user.get("msExchMailboxGUID")

$thisDN2 = $twoUser.DistinguishedName
$user2 = [ADSI]"LDAP://$thisDN2"

$user2.put('msExchMailboxGUID', @($guid))
$user2.setinfo()