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

7,669

Continuing from your example, this would work:

$guid = $user.get("msExchMailboxGUID")
$thisDN2 = $twoUser.DistinguishedName
$user2 = [ADSI]"LDAP://$thisDN2"
$user2.put('msExchMailboxGUID', @($guid))
$user2.setinfo()
Share:
7,669
Juanjo Daza
Author by

Juanjo Daza

Updated on September 18, 2022

Comments

  • Juanjo Daza
    Juanjo Daza 11 months

    I need to set the msExchMailboxGUID for many accounts in bulk. My input for this data comes from the Powershell command Get-MailboxStatistics. In it is an object that has the GUID for the mailbox.

    I need to save that GUID into AD, so this is what I'm doing to GET the object:

       $thisDN = $oneUser.DistinguishedName
       $user = [ADSI]"LDAP://$thisDN"  
      try 
      {
         $user.get("msExchMailboxGUID")
      }
      catch
      {
          $desc = ""
      }
    

    What is the correct way to Set the object?

    I'm unable to use "set" or "put" to upload and save the error. It would even be better if someone can point me to detailed object details since I'm not sure where to look for details on something that is instantiated with the [ADSI] brackety thing.

    If this is just using the COM ADSI objects, then what is the correct syntax for "put"? I've tried parentheses, commas, and am unable to get Powershell to talk COM.

    • jscott
      jscott over 10 years
      Do you not have available the Microsoft ActiveDirectory modules included with RSAT? Are you using ADSI for a specific reason?
    • Juanjo Daza
      Juanjo Daza over 10 years
      @jscott I thought ADSI was the way... perhaps this is a lot easier than I thought. What term should I google? My search terms lead me down the ADSI path.
    • Juanjo Daza
      Juanjo Daza over 10 years
      Hmmm seems like Import-Module ActiveDirectory may help me