How To Automate Powershell Universal Dashboard Installation In Azure? 1 Best Example

PowerShell Universal Dashboard is a powerful web framework that allows you to build and publish interactive dashboards, reports, and web applications using PowerShell. In an Azure environment, automating the installation of PowerShell Universal Dashboard can save time and effort when deploying dashboards on virtual machines (VMs).

Automate Powershell Universal Dashboard Installation

In this article, we will walk you through the process of automating the installation of PowerShell Universal Dashboard in Azure using Azure PowerShell and ARM templates.

Automate Windows PowerShell Universal Dashboard Installation

To automate the installation of the PowerShell Universal Dashboard in Azure, you can use the PowerShell and Azure Resource Manager (ARM) templates. The following steps will guide you through the process:

Create an Azure Resource Manager (ARM) Template:

  • Start by creating an ARM template (JSON file) that describes the Azure resources you want to deploy. In this case, you’ll define a Virtual Machine (VM) to run your PowerShell Universal Dashboard.
  • Include necessary settings such as VM size, OS image, networking configuration, etc.
  • Make sure to also include a script extension resource that will execute a PowerShell script to install PowerShell Universal Dashboard on the VM.

Prepare the PowerShell Script:rong>

  • Create a PowerShell script that installs PowerShell Universal Dashboard on the VM. You can use the Install-Module and Import-Module cmdlets to download and import the Universal Dashboard module.
  • After installation, you can start a dashboard by using the Start-UDDashboard cmdlet.

Use Azure PowerShell to Deploy the ARM Template:

  • Open PowerShell or PowerShell ISE on your local machine.
  • Login to your Azure account using Connect-AzAccount.
  • Select the Azure subscription where you want to deploy the resources using Set-AzContext.
  • Use the New-AzResourceGroup cmdlet to create a new resource group for the deployment.
  • Deploy the ARM template using the New-AzResourceGroupDeployment cmdlet. Specify the template file path and any necessary parameter values.
  • Wait for the Deployment to Complete:

Depending on the complexity of your ARM template and the VM size, the deployment might take some time to complete. Use the Get-AzResourceGroupDeployment cmdlet to check the deployment status.

Access the PowerShell Universal Dashboard:

  • Once the deployment is successful, you can access your PowerShell Universal Dashboard by using the public IP address or DNS name of the VM.
  • Note: The specific details and commands will depend on your exact scenario and configuration. Ensure you have the necessary permissions in Azure to create resources and deploy ARM templates.

Here’s an example of what the PowerShell script in the ARM template may look like:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vmName": {
      "type": "string",
      "metadata": {
        "description": "Name of the virtual machine."
      }
    },
    "adminUsername": {
      "type": "string",
      "metadata": {
        "description": "Username for the virtual machine."
      }
    },
    "adminPassword": {
      "type": "securestring",
      "metadata": {
        "description": "Password for the virtual machine."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2021-03-01",
      "name": "[parameters('vmName')]",
      "location": "[resourceGroup().location]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_DS2_v2"
        },
        "osProfile": {
          "computerName": "[parameters('vmName')]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2019-Datacenter",
            "version": "latest"
          },
          "osDisk": {
            "createOption": "FromImage"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('vmName'), '-nic'))]"
            }
          ]
        }
      },
      "resources": [
        {
          "type": "Microsoft.Network/networkInterfaces",
          "apiVersion": "2021-02-01",
          "name": "[concat(parameters('vmName'), '-nic')]",
          "location": "[resourceGroup().location]",
          "properties": {
            "ipConfigurations": [
              {
                "name": "ipconfig1",
                "properties": {
                  "subnet": {
                    "id": "[variables('subnetRef')]"
                  },
                  "privateIPAllocationMethod": "Dynamic"
                }
              }
            ]
          }
        },
        {
          "type": "Microsoft.Network/virtualNetworks",
          "apiVersion": "2021-05-01",
          "name": "[variables('vnetName')]",
          "location": "[resourceGroup().location]",
          "properties": {
            "addressSpace": {
              "addressPrefixes": [
                "10.0.0.0/16"
              ]
            },
            "subnets": [
              {
                "name": "default",
                "properties": {
                  "addressPrefix": "10.0.0.0/24"
                }
              }
            ]
          }
        }
      ]
    },
    {
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2020-12-01",
      "name": "[concat(parameters('vmName'), '/installDashboard')]",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[parameters('vmName')]"
      ],
      "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.10",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "fileUris": [
            "https://path/to/your/powershell_script.ps1"
          ],
          "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File powershell_script.ps1"
        }
      }
    }
  ],
  "variables": {
    "vnetName": "myVNet",
    "subnetName": "mySubnet",
    "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), variables('subnetName'))]"
  },
  "outputs": {
    "vmIPAddress": {
      "type": "string",
      "value": "[reference(parameters('vmName')).privateIps]"
    }
  }
}
Automate Powershell Universal Dashboard Installation

The above template includes the necessary resources to deploy a virtual machine and execute a PowerShell script extension to install PowerShell Universal Dashboard.

Remember to replace  https://path/to/your/powershell_script.ps1 in the ARM template with the actual URL of your PowerShell script.

Once you have the ARM template and the PowerShell script prepared, follow the steps in the previous response to deploy it using Azure PowerShell. The template will create a VM, execute the script extension to install PowerShell Universal Dashboard and output the public IP address of the VM to access the dashboard.

Please note that the specific cmdlet versions and APIs mentioned in the ARM template and the script might have been updated since the knowledge cutoff date (September 2021). Ensure you are using the latest versions when implementing the automation.

Meet the Author

Abdul Rahim has been working in Information Technology for over two decades. Learn how Abdul got his start as a Tech Blogger , and why he decided to start this Software blog. If you want to send Abdul a quick message, then visit his contact page here.