How do we bulk change Distribution List Primary SMTP from contoso.onmicrosoft.com to contoso.com

%3CLINGO-SUB%20id%3D%22lingo-sub-887703%22%20slang%3D%22en-US%22%3EHow%20do%20we%20bulk%20change%20Distribution%20List%20Primary%20SMTP%20from%20contoso.onmicrosoft.com%20to%20contoso.com%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-887703%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20we%20bulk%20change%20100%20Distribution%20List%20Primary%20SMTP%20from%20%3CSTRONG%3Econtoso.onmicrosoft.com%3C%2FSTRONG%3E%20to%3CSTRONG%3E%20contoso.com%20%3C%2FSTRONG%3Evia%20powershell%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-887703%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-890093%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20we%20bulk%20change%20Distribution%20List%20Primary%20SMTP%20from%20contoso.onmicrosoft.com%20to%20contoso.com%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-890093%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F61448%22%20target%3D%22_blank%22%3E%40Marvin%20Oco%3C%2FA%3Ewith%20something%20like%20that%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EGet-DistributionGroup%20%7C%20%3F%20%7B%20%24_.PrimarySmtpAddress%20-like%20%22*%40contoso.onmicrosoft.com%22%7D%20%7C%20%25%20%7B%20Set-DistributionGroup%20-PrimarySmtpAddress%20%22%24(%24_.PrimarySmtpAddress.Split('%40')%5B0%5D)%40contoso.com%22%20-WhatIf%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Super Contributor

 

 

How do we bulk change 100 Distribution List Primary SMTP from contoso.onmicrosoft.com to contoso.com via powershell?

1 Reply
Highlighted

@Marvin Ocowith something like that:

 

 

Get-DistributionGroup | ? { $_.PrimarySmtpAddress -like "*@contoso.onmicrosoft.com"} | % { Set-DistributionGroup -PrimarySmtpAddress "$($_.PrimarySmtpAddress.Split('@')[0])@contoso.com" -WhatIf }