0 votes

I've got the following script as part of a larger piece where param-members is an AD Object picker list seperated by a ' ; ' currently:

New-DistributionGroup -Name 'U_Mailbox - %param-company% %param-mailbox-name%' -Alias '%param-mailbox-name%.group' -DisplayName 'U_Mailbox - $company %param-mailbox-name%' -OrganizationalUnit '%param-company%' -PrimarySMTPAddress '%param-mailbox-name%.group@%param-domain' -members '%param-members%'

The problem is that param-members provides the DN of the User object and I either need that to be in "" or convert that to username but I'm struggling to achieve that with multiple Users selected

by (220 points)
edited by

1 Answer

0 votes
by (213k points)


The parameter value is an array of distinguished names (DNs) separated by the value specified in the parameter settings. As a solution, you can iterate through the DNs, form the required list and then pass it to the -Members parameter. For an example on how to use parameter values in such a way, have a look at Script 1: Add temporary membership of the following article in our repository: https://www.adaxes.com/script-repository/temporary-group-membrship-s533.htm.

Also, to execute the New-DistributionGroup cmdlet, you will need to connect to Exchange. For details, see https://www.adaxes.com/script-repository/connect-to-exchange-with-powershell-s506.htm.

Related questions

0 votes
1 answer

Trying to create a new group and getting the following error: "The name reference is invalid. (Server: example.com)" I've created groups before...the problem seems to have just ... a new Group object. It has me puzzled so I'm looking for some direction...

asked Feb 28, 2014 by RickWaukCo (300 points)
0 votes
1 answer

I'm learning the Adaxes powershell methods for creating objects. I would like to create a contact that is mail enabled. I attempted to use the example but it failed ... example of how to create a mail enabled contact with PowerShell using the New-AdmObject?

asked Jul 29, 2020 by ComputerHabit (790 points)
0 votes
1 answer

I've got the following script so far using the SDK but running into an error: You cannot call a method on a null-valued expression. At line:1 char:1 + ... .BindToObjectByDN("$object.SearchResult.AdsPath.DN") $Context.Items.Add($item, $columnValues) } } } }

asked May 19, 2021 by richarddewis (220 points)
0 votes
1 answer

Good afternoon, I'm looking to generate a script to allow automation of updating job titles using a spreadsheet. To do this we would use a spreadsheet generated by ... in calling the file. Please let me know if you require any additional information Regards

asked Nov 16, 2020 by jtop (680 points)
0 votes
0 answers

I have created a Custom action to create some "standard" sub OUs to a particular type of OU in our AD. I wanted to create a script to look in the OU you are executing ... 'Users') -or ($child.Name -eq 'Computer Systems')) {$Context.ConditionIsMet = $False } }

asked Aug 31, 2016 by ggallaway (300 points)
2,634 questions
2,369 answers
969,208 users