How to set msExchMailboxGuid with Set-ADUser command

Jack Chuong 411 Reputation points
2023-02-10T07:45:29.95+00:00

Hi all,

I get users information (PrimarySMTPAddress,Alias,SamAccountName,FirstName,LastName,DisplayName,Name,ExchangeGuid,ArchiveGuid,LegacyExchangeDn,EmailAddresses) by Get-Mailbox command

Then export them to XML file (Export-Clixml) or CSV file (Export-Csv) .

How do I use Set-ADUser command to set msExchMailboxGuid property for user ?

$NewUsersList = Import-CSV "aduser.csv"
#Or
$NewUsersList = Import-Clixml "aduser.xml"
ForEach ($User in $NewUsersList) {
New-ADUser...
Set-ADUser -Identity $User.SamAccountName -Replace @{msExchMailboxGuid=$User.
msExchMailboxGuid # get error Set-ADUser : A value for the attribute was not in the acceptable range of values
}
Microsoft Exchange Online
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,639 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,578 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,592 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,651 Reputation points Microsoft Vendor
    2023-02-13T01:55:21.85+00:00

    Hi @Jack Chuong,

    Please try the following script and use if it can work for you:

    $NewUsersList = Import-CSV "aduser.csv"
    ForEach ($User in $NewUsersList) {
    Set-ADUser -Identity $User.SamAccountName -Replace @{msExchMailboxGuid=[GUID]$User.ExchangeGuid}
    }
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.