Azure PowerShell

Download and install the Azure Portal app with PowerShell

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:

  • Create a Temp folder under C:\ if this not already exists.
  • Create a Azure Portal app folder under the Temp folder if this not already exists.
  • Download the AzurePortalInstaller.exe file and save it under the Azure Portal app folder.
  • Install the Azure Portal app.
  • Delete the Azure Portal app folder and the AzurePortalInstaller.exe file after installation.
  • Close the Windows Terminal (or Windows PowerShell) window.


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 or Windows 10. 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. Three seconds after the completion of the script the Windows Terminal (or PowerShell) window will be closed.
 
.NOTES
 
Filename:       Download_and_install_the_Azure_Portal_app.ps1
Created:        02/01/2020
Last modified:  02/01/2020
OS:             Windows Server 2016/2019 or Windows 10        
PowerShell:     5.1
Version:        1.0
Author:         Wim Matthyssen
Twitter:        @wmatthyssen
Action:         Change variables were needed to fit your needs
Disclaimer:     This script is provided "As IS" with no warranties.
 
.EXAMPLE
 
.\Download_and_install_the_Azure_Portal_app.ps1
 
.LINK
 
https://tinyurl.com/td9423z
#>
 
## Variables

$scriptName = "Download_and_install_the_Azure_Portal_app"
$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
$writeEmptyLine = "`n"
$writeSeperator = " - "
$writeSpace = " "
$time = Get-Date -UFormat "%A %m/%d/%Y %R"
$foregroundColor1 = "Red"
$foregroundColor2 = "Yellow"
 
##-------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Start script execution

Write-Host ($writeEmptyLine + "#" + $writeSpace + $scriptName + $writeSpace + "script started" + $writeSeperator + $time)`
-foregroundcolor $foregroundColor1 $writeEmptyLine 
 
##-------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Create C:\Temp folder if not exists
 
If(!(test-path $tempFolder))
{
New-Item -ItemType $itemType -Force -Path $tempFolder | Out-Null
}
 
Write-Host ($writeEmptyLine + "#" + $writeSpace + $tempFolderName + $writeSpace + "folder available" + $writeSeperator + $time)`
-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 + "#" + $writeSpace + $azurePortalAppFolderName + $writeSpace + "folder available in"`
+ $writeSpace + $tempFolderName + $writeSpace + "folder" + $writeSeperator + $time)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
##----------------------------------------------------------------------------------------------------------------------------------------------------
 
## Download the Azure Portal app to Temp folder
 
(New-Object System.Net.WebClient).DownloadFile($azurePortalAppUrl, $azurePortalAppPath)
 
Write-Host ($writeEmptyLine + "#" + $writeSpace + $azurePortalAppExe + $writeSpace +  "available" + $writeSeperator + $time)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
##-------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Install the Azure Portal app
 
& $azurePortalAppPath
 
Write-Host ($writeEmptyLine + "# The" + $writeSpace + $AzurePortalAppFolderName + $writeSpace`
+ "is installed, you can now logon with your credentials" + $writeSeperator + $time)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
##-------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Remove AzurePortalInstaller.exe file and Azure Portal app folder from Temp folder after installation
 
Start-Sleep 2
Get-ChildItem -Path $tempAzurePortalAppFolder -Force -Recurse  | Remove-Item -Force -Recurse
Remove-Item $tempAzurePortalAppFolder -Force -Recurse
 
Write-Host ($writeEmptyLine + "#" + $writeSpace + $azurePortalAppExe + $writeSpace + "and"`
+ $writeSpace + $AzurePortalAppFolderName + $writeSpace + "folder is removed" + $writeSeperator + $time)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
 
##-------------------------------------------------------------------------------------------------------------------------------------------------------
 
## Exit Windows PowerShell window 3 seconds after completion
 
Write-Host ($writeEmptyLine + "# Script completed, the PowerShell window will close in 3 seconds" + $writeSeperator + $time)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
Start-Sleep 2 
stop-process -Id $PID
 
##-------------------------------------------------------------------------------------------------------------------------------------------------------


To use the script, copy and save the above as Download_and_install_the_Azure_Portal_app.ps1 or download it from GitHub. Afterwards run the script from within Windows Terminal or Windows PowerShell (or any other tool you prefer).



The app will automatically open after installation. You can then 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 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, 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.


%d bloggers like this: