Help Center
< All Topics
Print

Introduction

It is often easier to develop PowerShell scripts that are intended to run in Azure by first running and debugging them on a local desktop computer. This is how the existing Speakeasy scripts have been developed. 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

Note: since this guide was written, a new extension has been added to Visual Studio Code which enable Azure runbooks to be executed directly on the local computer (currently, when developing locally, a copy of the script is made, which is  not ideal). Once the extension has been tried, some of the requirements listed below may need to be changed. However, for now, follow these as listed.

Azure Connectivity

Install the modules that are used to establish a connection to Azure:
    Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force -AllowClobber

Sharepoint Connectivity

Install the modules that are used to establish a connection to Sharepoint:
    Install-Module -Name “PnP.PowerShell”

Exchange Connectivity

Install the modules that are used to establish a connection to Exchange:
    Install-Module -Name ExchangeOnlineManagement

Digital Certificate

For debugging of Azure-based scripts on the local desktop, need to load any digital certs into the local certificate store. The following PowerShell script will do this:
PMCAppForTraining7_LoadCertToLocalStore.ps1

Digital Certificate Password

When executing any of the PowerShell scripts for loading or saving digital certificates, use the password which is stored in BitWarden for the entry called “Azure Digital Certificate Password”
Note: If using Visual Studio code to edit/run PowerShell scripts that involve Exchange/Sharepoint/Azure connectivity, it is recommended that Visual Studio code is restarted after the above have been installed, as the environment may not be fully configured without the restart/