Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this tutorial, we will create and publish an Azure AD PowerShell Workflow using the WFS. Please read through the concepts and important properties to know more about how WFS supports executing PowerShell cmdlets. We will cover the following in this tutorial.

...

Note

This tutorial assumes that the reader knows how to create a basic workflow. Please consider following the instructions here to create a basic workflow.

  1. In the Workspace tree of Solution Explorer, right-click the Package node where you want to create the Workflow and select New Workflow > Flow Chart Workflow from the context menu.

  2. The Workflow Designer will load a flowchart workflow with default shapes and names.

  3. Save the Workflow with an appropriate name. Click on the Save icon, provide a File Name in the dialog, and click the Save button. Once you save the Workflow, the WFS will reload the Workflow. In the screenshot below, we are saving the Workflow with the Name AzureUsersWF.

    Image RemovedImage Added

  4. Let’s add an activity. Click on the Activities Tab and Search for AzXPowerShellActivity. Drag and drop the Activity to the designer window.

  5. Select the Activity, click on the Properties tab and change the Name to meaningful.

    Image RemovedImage Added

  6. Right-click on the Activity and select Edit Get/Set Data logic in the context menu.

  7. Add a using reference to the PowerShell library.

    Code Block
    using PS = TheDotNetFactory.Framework.PowerShell;

  8. Paste the code for the SetDataCode method. Please ensure the following important property values are correctly set for the code to work.

    • PSServiceType : Set the value of PSServiceType to AzPowerShellType.AzureAD to make the AzXPowerShellActivity work with Azure AD.

    • AccountStoreID: Set the value to the right account store so that the current user executing the PowerShell commands can be authenticated.

      Code Block
      public virtual void SetDataCode(uni.WorkflowExecutor context, uni.IActivity activity)
              {
                  try
                  {
                   PS.PSCommand cmd = new PS.PSCommand();
                   cmd.IsScript = true;
                   cmd.CommandText = "Get-AzureADUser -Top 50 | Select DisplayName, Mail, ObjectId | ConvertTo-Json";
       
                   var commands = new List<PS.PSCommand>();
                   commands.Add(cmd);
       
                   this.CurrentWorkflow.GetADUsersCmdlet.PSServiceType = AzPowerShellType.AzureAD;
                   this.CurrentWorkflow.GetADUsersCmdlet.AccountStoreID = 2615;
                   this.CurrentWorkflow.GetADUsersCmdlet.Commands = commands;
                   this.CurrentWorkflow.GetADUsersCmdlet.RestrictDelayToSameServer = true;
                   this.CurrentWorkflow.GetADUsersCmdlet.EnablePassiveResultsHandling = false;
                   this.CurrentWorkflow.GetADUsersCmdlet.MaxWaitLoopCount = 10;
                   TdnfTrace.Current.TraceData(TraceEventType.Verbose, 411, "!!!!!######Starting to execute the command: " + cmd.CommandText);
                  }
                  catch(Exception ex)
                  {
                      TdnfTrace.Current.TraceData(TraceEventType.Verbose, 411, "!!!!!######Something blew up executing the command");
                  }
            }

  9. Now, add another activity to receive the results from the PowerShell commands. Search for DynamicPowershellResultsGrid in the Activities tab and drag-drop the Activity to the designer.

  10. Select the Activity, click on the Properties tab and change the Name to something meaningful. In this example, we renamed it to ShowUserResults.

  11. Paste the code into the GetDataCode method.

    Code Block
     public virtual void GetDataCode(uni.WorkflowExecutor context, uni.IActivity activity)
             {
                this.CurrentWorkflow.ShowUserResults.Result = this.CurrentWorkflow.GetADUsersCmdlet.Results;
            }

  12. Please ensure all the activities are connected, and the necessary codes are included in the methods as instructed above.

  13. Click on the Compile icon to compile the activity code.

...

We are all set to publish the Workflow. Please follow the instruction, and information about publishing the workflow items can be found here.

Verify the Workflow is Working

  1. Log in to your EmpowerID portal.

  2. Navigate to Object Administration → Workflows.

  3. Search the Workflow published earlier and click on the workflow name in the Run column to execute the Workflow.

    Image RemovedImage Added

  4. You should be able to see the Grid that populates the users from the Azure AD.

    Image RemovedImage Added

Insert excerpt
IL:External Stylesheet
IL:External Stylesheet
nopaneltrue

Macrosuite divider macro
dividerWidth100
dividerTypetext
emoji{"id":"smile","name":"Smiling Face with Open Mouth and Smiling Eyes","short_names":["smile"],"colons":":smile:","emoticons":["C:","c:",":D",":-D"],"unified":"1f604","skin":null,"native":"😄"}
textColor#000000
dividerWeight3
labelPositionmiddle
textAlignmentcenter
iconColor#0052CC
fontSizemedium
textRelated Pages
emojiEnabledfalse
dividerColor#DFE1E6
dividerIconbootstrap/CloudsFill

Page Tree
root@self
startDepth1