Attached is a very small WFA command that uses the Windows ServerManager ActiveDirectory commands to create an AD group. I can cut/paste the try/catch statement to a PoSH window and it executes as expected and creates the group. When I am in WFA and editing the command and use the [Test] button or execute it in a workflow it seems to do nothing and gives no error.
PS: the basic code is pasted below. When I cut/paste the logic to PoSH window I comment the WFALogger command and use the write-output "$errMsg" instead. It runs, and when it runs twice it catches the error that the groupName already exists.
I presume the New-ADGroup cmdlet requires administrator privileges but I don't know what prig-level or account WFA command run under.
I don't think this needs to be done at command level, every single time the command executes. RSAT loading could take time and its a one-time activity. So I suggest you do it from outside once and only use Import-module ActiveDirectory in the command.
Message was edited by: Abhishek Sinha
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.