Share via

How to set msExchMailboxGuid with Set-ADUser command

Jack Chuong 436 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
}
Exchange Online
Exchange Online

A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Kai Yao 37,791 Reputation points Moderator
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.

Was this answer helpful?

3 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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