The CreatorCon Call for Content is officially open! Get started here.

Automating Distribution List (DL)

catchdini
Tera Expert

Hello All, We have an requirement to automate DL tasks such as creating a DL, updating a DL (add or remove users in a DL) and delete a DL. Can someone please share some inputs and the way to achieve this. I have enabled Orchestration plugin for this. Thanks in advance.

17 REPLIES 17

Thanks Robert for pointing to the link. Thats helpful. I used a Run PowerShell activity in a workflow and used Remove-DistributionGroup "<Distribution Group Name>". I see an error message as below




The activity is as below. Im passing the dl from the request to a scratchpad and hence using what I have in scratchpad.


Delete DL.jpg



*** The term 'Remove-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.Stack Trace:       at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)


Hello Catch,



I didn't realize that the link I gave you uses their own remote connection script. You would need to follow this to make sure that you load the prerequisite module and script: Connect to Office 365 and Exchange Online using a Script - o365info.com.



After reading that, I would probably stick with Microsofts OOB tools, though: Exchange Online PowerShell: Exchange Online Help



Either way, you need to make sure that the module/plugin is installed on the host machine, and loaded in script, before you can execute a cmdlet.


Thank you Robert. I will install the plugin in the host machine and see how it goes.


Hello Robert, Installed the components and my Run Powershell Activity has the command


Add-ADGroupMember workflow.scratchpad.dlName workflow.scratchpad.users


where workflow.scratchpad.dlName has the DL Name used in the request, which is stored in the scratchpad and


                  workflow.scratchpad.users has the user used in the request, which is stored in the scratchpad



I see an error in the workflow showing as below.


powershell.jpg



I also tried with Add-ADGroupMember workflow.scratchpad.dlName users but again same issue. What could be the problem?




It looks like the variables aren't being resolved. You need to enclose them in ${ }. Does this work?


Add-ADGroupMember "${workflow.scratchpad.dlName}" "${workflow.scratchpad.users}"


Although, the error specifically references 'current.variables.user'. Can you post the full script?