Powershell scrip to assign email address with a specific domain RRS feed

  • Question

  • Hi All,

    Many thanks in advance and I am in need of to change the existing primary SMTP address and remove alias email addresses of few users/groups which are associated with a particular domain. So, I am using the script which is as shown below:

    $NewDomain = domain
    $MBX= import-csv filepath
    foreach($MB in $MBX){
    $Users = get-remotemailbox -identity $_.MB}
    $Users | foreach-object{
    $UserName =($user.PrimarySmtpAddress -split "@")[0]
    $SMTP ="SMTP:"+ $UserName +"@"+$NewDomain
    $user | Set-RemoteMailbox -EmailAddresses $SMTP -primarysmtpaddress $Emailaddress}

    The script is picking the New domain details and merging it with $username, but after that I am getting an error message that no Parameter is found for the argument to be assigned. Requesting to kindly help on this issue.

    A brief of how or infrastructure is setup. The on-prem domain is in Hybrid with Office365 and few domains are getting moved from office365. Now to remove these domains there are dependancies showing up for which I have to remove email addresses of that domain for users/groups. So, requesting to kindly let me know where I am faulting out.

    Many Thanks,



    • Moved by Bill_Stewart Sunday, July 29, 2018 11:31 PM This is not "fix/debug/rewrite my script for me" forum
    Tuesday, June 5, 2018 3:46 PM