This section contains information on automation workflow enhancements that enable you to add Azure or Office 365 modules in PowerShell and run the Office 365 services such as Skype for Business, Azure AD, Azure RM, Az, and Sharepoint Powershell scripts within existing Active Roles workflows.
As part of creating automation workflow, a new activity O365ScriptExecutionConfiguration is added to fetch the already configured tenant details. However, if required, you can override Office 365 script execution activity by editing the O365 User and O365 Password workflow parameters by double click on the O365ScriptExecutionConfiguration activity.
These modules must be to be installed to make the import and connect the module and execute the powershell script.
Install modules azurerm, azuread, az, skype for business and Sharepoint , for exchange online is connected to online poweshell hence https://outlook.office365.com/powershell-liveid/ should not be blocked and network connectivity is available
From the tool box within the workflow, select O365ScriptExecutionConfiguration.
From the within the workflow, select the Script activity and configure the script activity to point to the powershell script and function to execute.
NOTE: The string or command entered in the API O365ExecuteScriptCmd must be well formed and complete for the workflow to run successfully.
This script enables the multiple modules specified in the array to be loaded and creates a connection to the modules with the login details retrieved through O365ScriptExecutionConfiguration activity. The O365 User and O365 Password parameters that are configured earlier within workflow are used.
$array = @(“MSOnline”, “Lync”)
This enables the single module specified in the script to be loaded.
$context.O365ImportModule(“AzureRm) #latest version azureRm is imported
$context.O365ImportModule(“AzureRm, 4) #latest version azureRm version 4 is imported
Passing any string or command specified in the script will execute and return the results as PSObject.
This script disconnects the PSSessions and removes the modules from the PowerShell pool, and allows to import new modules again.
$context.O365ExecuteScriptCmd("Get-AzureADDirectoryRole | Export-csv "+$_default_log )
$context.O365ImportModule(“sharepoint”) # imports the sharepoint module make sure the sharepoint is installed and is able to import
$context.O365ConnectSharePoint("https://xxxxx-admin.sharepoint.com") #makes the connection Connect-SPOService with already configured tenant details or overridden tenant details
$context.O365ExecuteScriptCmd("Get-SPOUser -site 'https://xxxx.sharepoint.com'" +" | Export-Csv " +"c:\temp\SharePointUsers.csv" +" -NoTypeInformation") #exports the sharepoint users
In Active Roles, administrators can configure workflow activities of the pre-defined types that are installed with Active Roles. By default, the list of activities in the Workflow Designer contains only the pre-defined activity types, such as Approval Activity or Notification Activity. It is possible to extend the list by adding new types of activity.
Each activity type determines a certain workflow action (for example, originating an approval task or notification) together with a collection of activity parameters to configure the workflow action (for example, parameters that specify the approvers or notification recipients). Active Roles builds upon this concept, providing the ability to implement and deploy custom types of workflow activity. It enables custom activity types to be created as necessary, and listed in the Workflow Designer along with the pre-defined activity types, allowing administrators to configure workflow activities that perform custom actions determined by those new types of workflow activity.
Active Roles allows the creation of custom activities based on the Script Activity built-in activity type. However, creating and configuring a script activity from scratch can be time-consuming. Custom activity types provide a way to mitigate this overhead. Once a custom activity type is deployed that points to a particular script, administrators can easily configure and apply workflow activities of that type, having those activities perform the actions determined by the script. The activity script also defines the activity parameters specific to the activity type.
Custom activity types provide an extensible mechanism for deploying custom workflow activities. This capability is implemented by using the Policy Type object class. Policy Type objects can be created by using the Active Roles console, with each object representing a certain type of custom workflow activity.
The deployment process involves the development of a script that implements the workflow action and declares the activity parameters; the creation of a Script Module containing that script; and the creation of a Policy Type object referring to that Script Module. To deploy an activity type to a different environment, you can export the activity type to an export file in the source environment and then import the file in the destination environment. The use of export files makes it easy to distribute custom activity types.