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 (260 points)
edited by

1 Answer

0 votes
by (279k points)

Hello,

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 (320 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

Maybe there is a better way to accomplish this, so I'm open to suggestion. We are in a hybrid setup between onprem and M365. When we create a new user, they are ... command in the previous step, right? If needed, I can provide the full script. Thanks!

asked Nov 2, 2023 by AndrewMeyer (20 points)
0 votes
1 answer

Receive "Index operation failed; the array index evaluated to null. Stack trace: at <ScriptBlock>, <No file>: line 104>" and "Index operation failed; the ... $GroupName, $GroupDN." } } #foreach write-output "" Write-Output "" Stop-Transcript

asked Apr 14, 2022 by jbahou (20 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 (260 points)
3,430 questions
3,127 answers
7,969 comments
546,252 users