The illustration below gives you an abstracted view of automated task execution within the MSPComplete automation framework. The illustration assumes that a Runbook has been instantiated and is running as a service.
- An automated task is launched. An automated task can be launched in either of two ways. Either an agent launches the action by clicking a button (or some other action), or the task can be configured to auto-run on successful conclusion of the previous task.
- The platform creates a virtual execution container. The execution container provides for isolation of the script execution. Every automation script has its own virtual execution container created at runtime.
- The platform spins up the BitTitan scripting host. The scripting host is an execution engine that ingests and executes the script. In doing so, it performs a number of important actions:
- The host retrieves context information from the MSPComplete data store, including the ID of the service instance in which the task exists, as well as the authorization ticket for the agent who launched the service. The context information may include stored values that are being passed to the current task from a previous task.
- The scripting host performs a series of operations:
- It executes the specified script
- It provides context variables ($mspc, for example), context data, and input parameters, if any.
- It captures script output and makes it available in MSPComplete UI.
Working with BitTitan applications
Using PowerShell scripts to interact with BitTitan products like MigrationWiz is not new. What’s new are enhancements to the BitTitan automation model, which includes the scripting host to enable automation using PowerShell scripts.
Following are some notable improvements:
- The latest version of the BitTitan PowerShell module is pre-installed in the execution container where the BitTitan scripting host is running.
- The BitTitan PowerShell module itself is pre-loaded (no need to use import-module to load it.)
- The script is provided with the appropriate BitTitan or MigrationWiz authentication tickets. This allows the script to work without explicitly asking for agent credentials.
Interacting with third-party system APIs
The automation framework allows MSPComplete to interact with external systems using standard APIs. Script authors have complete control over interactions with third-party applications, as well as having access to MSPComplete entities, so it is the responsibility of script authors to manage the integration and associated risks.
Following are some guidelines to follow when you are invoking external APIs from PowerShell:
- Use standard PowerShell commands like Invoke-WebRequest to invoke remote web service.
- Use standard PowerShell commands like Invoke-RestMethod to invoke REST APIs.
- Use Remove PowerShell to manage or remove systems such as Microsoft Exchange (both on-premise and Office 365.)
- Install and use 3rd party PowerShell modules available in the PowerShell Gallery.