Automating PowerShell Universal Dashboard Installation in Azure

Adam Bertram

Read more posts by this author.

If you know how to write PowerShell and need to build a graphical dashboard representing just about any data, check out PowerShell Universal Dashboard (UD). UD is an intuitive way to build great-looking dashboards and even forms using just PowerShell. Luckily, Universal Powershell Dashboard works in Azure!

Universal Powershell Dashboard is a PowerShell module available to be installed by running Install-Module -Name UniversalDashboard.Community. The community module is free but I encourage you to purchase the full version.

I’m not going to go into the ins and outs of UD, Adam Driscoll (UD’s developer) has written extensive documentation already on the topic.

UD needs a web server to run. You can choose to run UD on IIS or in an Azure Web App. I hate messing with on-prem infrastructure so I always choose to deploy resources into the cloud whenever I can. Since UD natively supports running in an Azure Web App, it’s the perfect cloud candidate.

I found that even though UD has docs for setting it up in Azure, I still was struggling with an easy way to get it going. I managed to come up with a rough PowerShell script to setup the latest instance for you all in one swoop.

It can use some work but I just needed this for an upcoming Pluralsight course I was working on. Feel free to improve upon it as you need. Hopefully, comments inside will explain everything well enough.



#region Create the Azure web app
$appSrvPlan = New-AzAppServicePlan -Name "$WebAppName-AppSrv" -Location $AzureLocation -ResourceGroupName $AzureResourceGroup -Tier Free
$null = New-AzWebApp -Name $WebAppName -AppServicePlan $appSrvPlan.Name -ResourceGroupName $AzureResourceGroup -Location $AzureLocation

#region Download UD
Save-Module UniversalDashboard.Community -Path $env:TEMP -AcceptLicense
$udModulePath = (Get-ChildItem -Path "$env:TEMP\UniversalDashboard.Community" -Directory).FullName

# Get publishing profile for the web app
$pubProfile = Get-AzWebAppPublishingProfile -Name $Webappname -ResourceGroupName $AzureResourceGroup
$ftpPubProfile = ([xml]$pubProfile).publishData.publishProfile | Where-Object { $_.publishMethod -eq 'FTP' }

## Build the cred to authenticate
$password = ConvertTo-SecureString $ftpPubProfile.userPWD -AsPlainText -Force
$azureCred = New-Object System.Management.Automation.PSCredential ($ftpPubProfile.userName, $password)

try {
	$webclient = New-Object -TypeName System.Net.WebClient
	$webclient.Credentials = $azureCred

	#region Create all folders
	Get-ChildItem -Path $udModulePath -Directory -Recurse | foreach {
		$path = $_.FullName.Replace("$udModulePath\", '').Replace('\', '/')
		$uri = "$($ftpPubProfile.publishUrl)/$path"
		$makeDirectory = [System.Net.WebRequest]::Create($uri)
		$makeDirectory.Credentials = $azureCred
		$makeDirectory.Method = [System.Net.WebRequestMethods+FTP]::MakeDirectory
		Write-Host "Creating folder [$path]..."
		$null = $makeDirectory.GetResponse()

	## Create a simple dashboard to bring the site up
	Set-Content -Path "$udModulePath\dashboard.ps1" -Value 'Start-UDDashboard -Wait'

	#region Upload all of the files
	Get-ChildItem -Path $udModulePath -File -Recurse | foreach {
		$path = $_.FullName.Replace("$udModulePath\", '').Replace('\', '/').Replace('.\', '')
		$uri = New-Object System.Uri("$($ftpPubProfile.publishUrl)/$path")
		Write-Host "Uploading file [$path]..."
		$null = $webclient.UploadFile($uri, $_.FullName)
} catch {
} finally {
	## Cleanup

I called the script New-UDAzureInstance.ps1 and launch it like:

PS> ./New-UDAzureInstance.ps1 -WebAppName ADBPoshUD -AzureResourceGroup 'Course-PowerShellDevOpsPlaybook' -AzureLocation 'East US'

Once you’ve got UD set up in Azure, you will then modify the dashboard.ps1 file to build any kind of dashboard you need.

Browse to the URL of your Azure Web App and bask in the glory of a freshly installed Universal Powershell Dashboard instance.

PowerShell Universal Dashboard in Azure
PowerShell Universal Dashboard in Azure

I hope this saves some people some time setting up Universal Powershell Dashboard in Azure!

Subscribe to Stay in Touch

Never miss out on your favorite ATA posts and our latest announcements!

Looks like you're offline!