Azure PowerShell

Download and install the Azure Portal app with PowerShell

 [January 11, 2022 – reviewed & updated]


In addition to the Azure Portal and the Azure mobile app, you can also use the Azure Portal app to access and manage all your Azure resources.

It foresees a user experience very similar to the web-based Azure Portal, but without the need of a browser. It provides you with all the same features, you are familiar from working with in the Azure Portal , such as the Azure Cloud shell, your Dashboard(s) and your Favorites. Beside that, you can view and manage all your Azure workloads, applications and services, like your Azure virtual machines, Virtual Network(s), Web Apps, Recovery Services Vault(s), etc. , but now directly from your desktop.

This lightweight application (app) especially comes in handy, when you want to securely connect (without the use of a browser) to the Azure Portal from any kind of Management server, or from a Windows client which has restrictions to use any kind of browser.

You can manually download and install the Azure Portal app, but to automate and speed up the download and installation process, I wrote the below PowerShell script which does all of the following:

  • Check if the PowerShell window is running as Administrator (which is a requirement), otherwise the Azure PowerShell script will be exited.
  • Create Temp folder on the C: drive, if the folder not already exists.
  • Create an Azure Portal app folder under the Temp folder if this not already exists.
  • Download the AzurePortalInstaller.exe file and save it in the Azure Portal app folder.
  • Install the Azure Portal app.
  • Delete the Azure Portal app folder and the AzurePortalInstaller.exe file after installation.


To use the script copy and save it as Download-and-Install-Azure-Portal-app.ps1 or download it from GitHub. First adjust all variables to your use and afterwards run the customized script with Administrator privileges from Windows PowerShellWindows Terminal, or Visual Studio Code.

PowerShell script

<#
.SYNOPSIS
 
A script used to download and install the Microsoft Azure Portal app.
 
.DESCRIPTION
 
A script used to download the Azure Portal app on a Windows Server 2016/2019/2022 or Windows 10/11. 
The .exe file will be downloaded in the Azure Portal app folder under the Temp folder. 
After installation the Azure Portal app folder and the .exe file will be deleted. 
 
.NOTES
 
Filename:       Download-and-Install-Azure-Portal-app.ps1
Created:        02/01/2020
Last modified:  11/01/2020
Author:         Wim Matthyssen
OS:             Windows Server 2016/2019/2022 or Windows 10/11        
PowerShell:     5.1
Requires:       -RunAsAdministrator
OS:             Windows 10, Windows 11, Windows Server 2016, Windows Server 2019 and Windows Server 2022
Version:        2.0
Action:         Change variables were needed to fit your needs.
Disclaimer:     This script is provided "As Is" with no warranties.
 
.EXAMPLE
 
Download-and-Install-Azure-Portal-app.ps1
 
.LINK
 
https://wmatthyssen.com/2020/01/02/download-and-install-the-azure-portal-app-with-powershell/
#>
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Variables

$tempFolderName = "Temp"
$tempFolder = "C:\" + $tempFolderName +"\"
$itemType = "Directory"
$azurePortalAppFolderName = "Azure Portal app"
$tempAzurePortalAppFolder = $tempFolder + $azurePortalAppFolderName
$azurePortalAppUrl = "https://portal.azure.com/app/Download?acceptLicense=true"
$azurePortalAppExe = "AzurePortalInstaller.exe"
$azurePortalAppPath = $tempAzurePortalAppFolder + "\" + $azurePortalAppExe

$global:currenttime= Set-PSBreakpoint -Variable currenttime -Mode Read -Action {$global:currenttime= Get-Date -UFormat "%A %m/%d/%Y %R"}
$foregroundColor1 = "Red"
$foregroundColor2 = "Yellow"
$writeEmptyLine = "`n"
$writeSeperatorSpaces = " - "
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Check if running as Administrator, otherwise close the PowerShell window

$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$isAdministrator = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ($isAdministrator -eq $false) {
    Write-Host ($writeEmptyLine + "# Please run PowerShell as Administrator" + $writeSeperatorSpaces + $currentTime)`
    -foregroundcolor $foregroundColor1 $writeEmptyLine
    Start-Sleep -s 5
    exit
}
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Start script execution

Write-Host ($writeEmptyLine + "# Script started. Without any errors, it will need around 1 minute to complete" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine 
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Create C:\Temp folder if not exists

If(!(test-path $tempFolder))
{
New-Item -Path "C:\" -Name $tempFolderName -ItemType $itemType -Force | Out-Null
}

Write-Host ($writeEmptyLine + "# $tempFolderName folder available" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Create Azure Portal app folder in C:\Temp if not exists
 
If(!(test-path $tempAzurePortalAppFolder))
{
New-Item -Path $tempFolder -Name $azurePortalAppFolderName -ItemType $itemType | Out-Null
}
  
Write-Host ($writeEmptyLine + "# $azurePortalAppFolderName folder available in the $tempFolderName folder" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Download the Azure Portal app to Temp folder
 
(New-Object System.Net.WebClient).DownloadFile($azurePortalAppUrl, $azurePortalAppPath)
 
Write-Host ($writeEmptyLine + "# $azurePortalAppExe available" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Install the Azure Portal app
 
& $azurePortalAppPath
 
Write-Host ($writeEmptyLine + "# The $AzurePortalAppFolderName is installed, you can now logon with your credentials" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Remove AzurePortalInstaller.exe file and Azure Portal app folder from Temp folder after installation
 
Start-Sleep 3
Get-ChildItem -Path $tempAzurePortalAppFolder -Force -Recurse  | Remove-Item -Force -Recurse
Remove-Item $tempAzurePortalAppFolder -Force -Recurse
 
Write-Host ($writeEmptyLine + "# $azurePortalAppExe and $AzurePortalAppFolderName folder are removed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Write script completed

Write-Host ($writeEmptyLine + "# Script completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine 

## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



If you ran the script on Windows 10 or 11 client device, it will open automatically after installation. And the other hand, if you ran the script on a Windows Server management server you will need to open the app manually. When opened, you can log in with your Azure credentials.


After the first use (or after you closed the app), you can open it from the Start menu or trough looking for it in the search bar.


Or open it, by opening Run and typing:

%LOCALAPPDATA%\Microsoft\AzurePortal\Production\MicrosoftAzurePortal.exe


Default Installation folder: C:\Users\{username}\AppData\Local\Microsoft\AzurePortal\Production



This concludes this blog post, and I hope this app will help you to do any Azure management related tasks whenever you are working from a Management server or when you are not allowed (security reasons) to use a browser in any way to connect to the Azure Portal.

If you have any questions or recommendations about it, feel free to contact me through my Twitter handle (@wmatthyssen) or to leave a comment.


0 comments on “Download and install the Azure Portal app with PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: