Introduction
It is often easier to develop PowerShell scripts that are intended to run in Azure by first running and debugging a copy of the script on a local desktop computer. This is how the existing Speakeasy scripts have been developed (but see the section at the end of this document for how to directly access an Azure runbook). To do this, a few steps need to be performed to make sure that all the appropriate software is configured on that computer. This document aims to highlight the requirements to ensure successful execution of the scripts on a local computer.
Requirements
PowerShell
The Azure Powershell scripts use two different PowerShell versions. At the time of writing, Speakeasy report generation would not work with V7.1 due to issues with the PDF component, so V5.1 was used. The following link shows the various versions used:
Speakeasy Automation Runbooks in Azure
Install V5.1 and V7.1 of PowerShell – it is recommended this is done using the latest .MSI files
Visual Studio Code
For PowerShell 5.1, PowerShell ISE can be used to develop and debug scripts. However, this is being phased out so it is recommended that Visual Studio Code be used. When trying to run PowerShell scripts for the first time in Visual Studio code, the user will be prompted to install additional addins to support PowerShell – when prompted, say yes to install them. The components below can then be installed by executing the stated commands from inside the Visual Studio Code – Terminal window.
Azure Connectivity
Sharepoint Connectivity
Exchange Connectivity
Digital Certificate
Digital Certificate Password
Debugging and Running Azure Runbook Scripts on a local computer, without making a copy
Prior to 2023, any prospective Azure Runbook was first tested on a local computer by taking a copy of the run book script and adding it to a file in the following folder:
Bury Speakeasy\Speakeasy IT – General\PowerShellScripts\AzureRunbookScriptCopiesForTestingLocally
This was not ideal as the developer has to be careful to keep the local copy contents in sync with the Azure runbook copy. A new extension was added to Visual Studio Code in early 2023. This enables Azure runbooks to be accessed directly in Azure, but still executed on the local computer. The following article describes how to install and configure the Azure Automation VS Code extension: