Distribution List

Hello,

I have about 1000 groups and would like to find an easier way to add at least two Owners in each group using shell.  The owners are the exchange admin (the same persons) for all the groups. Is there a shell command that can do this instead of doing it manually?

Than

July 17th, 2015 8:49pm

You can try something like the following.

Get-DistributionGroup -ResultSize Unlimited | Set-DistributionGroup -ManagedBy @{add="administrator name"}

You might test it first on a single group.

Free Windows Admin Tool Kit Click here and download it now
July 18th, 2015 1:19am

Hi Ed,

I tried your suggestion and I got an error:

The term 'Get-DistributionGroup' is not recognized as the name of a cmdlet, function, sc
ript file, or operable program. Check the spelling of the name, or if a path was include
d, verify that the path is correct and try again.

Any idea? T

July 18th, 2015 11:01pm

Ed,

The shell command works perfectly.  Just one more question, if I need to add two people at once, how will I add another name to the command so two people can be added at the same time? So far, you have it like this... @{add=JDoe@domain.onmicrosoft.com}, where will I add the next person? Or I have to run the command one name at a time?

Thanks.

Free Windows Admin Tool Kit Click here and download it now
July 19th, 2015 1:02am

@{add="jdoe","rroe"}

Or you could just run the command once for each name.

Please feel free to mark posts as an answer and/or helpful as appropriate.

July 19th, 2015 2:27am

Ed,

What if I only want to do this on let say 3 groups? How is the shell command is going to be?

Right now you have it like this: Get-DistributionGroup -ResultSize Unlimited  ...can we do it on a specific group?

I want to test this now in production, but I want to just do at least 1 or two groups before I apply it to all.  Thanks.

Free Windows Admin Tool Kit Click here and download it now
July 19th, 2015 5:40pm

>>> What if I only want to do this on let say 3 groups? How is the shell command is going to be?

@{add="jdoe","rroe","jblow"}

>>> Right now you have it like this: Get-DistributionGroup -ResultSize Unlimited  ...can we do it on a specific group?

Set-DistributionGroup -Identity "Some Group" -ManagedBy @{add="administrator name"}


July 20th, 2015 12:49am

Thank you very much, it worked!
Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 1:30am

You're welcome.  Happy to have helped.
July 20th, 2015 1:49am

Hi Ed,

Sorry but I ran into problem, I hope you can help me again. I am getting this error:

The action 'Set-DistributionGroup', 'ManagedBy', can't be performed on the obje
ct 'HELPDESK@DOMAIN.COM' because the object is being synchronized from your on-premises organization. This action should be performed on the object in your on-premises organization.

    + CategoryInfo          : NotSpecified: (:) [Set-DistributionGroup], RuleV
   alidationException
    + FullyQualifiedErrorId : [Server=1231239,RequestId=b5468-59b1-46
   ad-b6dc-fb3d65a1dee4,TimeStamp=7/20/2015 6:15:08 AM] [FailureCategory=Cmdl
  et-RuleValidationException] 6d12550,Microsoft.Exchange.Management.Recipie
 ntTasks.SetDistributionGroup

I was logged on to our on-premise server.  Logged on to O365/EAC, but still getting this error. I am doing this in production now.  Any help is greatly appreciated, thanks.

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 2:23am

You must make the change on-premises.
July 20th, 2015 11:44am

Ed,

I am already logged on to our on-premise server and still not recognizing the cmdlet.  The command only works online, but not on Premise. Any idea, thanks.

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 1:54pm

You're using the Exchange Management Shell, right?  You must have an on-premises Exchange server to run Exchange cmdlets.
July 20th, 2015 3:38pm

Yes, we have the on-premises Exchange server and I am using the Shell Run ISE as Administrator:

1. First, I log in with this command:

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

2. Then, I ran the script:

Set-DistributionGroup -Identity "Group1.onmicrosoft.com" -ManagedBy @{add="Admin1","Admin2"}

___________ I guess the way, I'm logging on to Exchange is wrong as it is pointing to ..Office365 instead of on-premises?

fyi, we have a Hybrid environment as we are currently migrating right now. And we also do the Dirsync to update AD attributes. Not sure, if that is related to my problem but just letting you know, thanks.

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 4:22pm

Don't do that.  Close the Exchange Management Shell, open it again and enter the commands you want.  Do not connect to Exchange Online.  You must make changes to synchronized recipients in on-premises Exchange.

Use Windows PowerShell to connect to Exchange Online, but don't use it for most management of synchronized recipients (with a few exceptions).

July 20th, 2015 6:14pm

Ed,

I closed the Exchanged Management Shell, reopened it and entered the command:

Set-DistributionGroup -Identity "Group1@domain.com" -ManagedBy @{add="Admin1","Admin2"}

This time I received this error:

Set-DistributionGroup : The term 'Set-DistributionGroup' is not recognized as the name of a cmdlet, function,

script file, or operable program. Check the spelling of the name, or if a path was included, verify that the

path is correct and try again.

At line:1 char:1

+ Set-DistributionGroup -Identity "Group1" -ManagedBy @{add="admin1","admin2"}

+ ~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (Set-DistributionGroup:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

It's still didn't work?

Free Windows Admin Tool Kit Click here and download it now
July 21st, 2015 1:41am

Either you didn't open the Exchange Management Shell or your account doesn't have rights.
July 21st, 2015 2:34am

I would never thought that Exchange Management Shell would be different from Windows Power Shells because in the past, I've been using the Windows PowerShell to run some of the cmdlets for Exchange or O365 and it's been working fine.  I searched for the Exchange Management Shell on the Exchange Server on premises and was able to locate it.  I applied the cmdlet and it worked.  The missing piece was found, lol.   Thank you very much Ed for sticking around.  Obviously, I'm a newbie to this area.  Tha
Free Windows Admin Tool Kit Click here and download it now
July 21st, 2015 10:11am

Hello Ed, 

I have another question for you which is related to this thread.  I know you've helped me in the past and I hope you can share some input on this:

I would like to add a name on the Distribution List under the box named "Senders who don't require message approval."  This is on the Message Approval area.  Is there a cmdlet for this?  We have thousands of DL and it would be easier if we can just run a script to add a name on this area.  

Thanks for your input. I Really appreciate it or anyone that can answer my question, thanks. 

July 30th, 2015 6:27pm

Set-DistributionGroup

https://technet.microsoft.com/en-us/library/bb124955(v=exchg.150).aspx

I believe that it's the BypassModerationFromSendersOrMembers parameter you're looking for, but you should read the documentation to be sure.

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 7:14pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics