In this blog post, I am going to show you how to install PowerShell for Azure Stack. This should be one of the first things you do after you install Azure Stack.
Prerequisites
Before we are able to install PowerShell for Azure Stack we have to register the PSGallery repository.
Open PowerShell with Elevated credentials on the machine you want to install Azure Stack PowerShell on. (Normally the Azure Stack Host if you are not connected via VPN) and type the following code.
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted |
Install the latest version of the Azure Stack PowerShell modules
Uninstall any existing versions
It is always best to uninstall any existing version of the PowerShell module first. This can be done by using the following PowerShell code in an elevated window.
Get-Module -ListAvailable | where-Object {$_.Name -like "Azure*"} | Uninstall-Module |
Once that finishes we have to clear up some folders also. This can be done by using the following PowerShell command
Cd "C:\Program Files\WindowsPowerShell\Modules"; get-childitem -include "Azure*" -recurse -force| remove-Item -Force -Recurse | |
Cd "C:\Users\AzureStackAdmin\Documents\WindowsPowerShell\Modules"; get-childitem -include "Azure*" -recurse -force| remove-Item -Force -Recurse |
You may find that there is nothing to be deleted but it’s always good to check. That’s what the error above shows.
Install the PowerShell Module
Open PowerShell with elevated permissions and type the following PowerShell cmdlet. Make sure to select yes when prompted.
Install-module -Name AzureRm.BootStrapper |
Now we need to install the latest Version of the AzureRM modules for Computer, Storage, Network, etc. At the time of this blog post, the current version is 2007-03-09-profile. In your elevated PowerShell Window use the following command.
use-AzureRMProfile -Profile 2017-03-09-profile -Force |
Now we can install the Azure Stack Modules by using the following PowerShell command
Install-Module -Name AzureStack -RequiredVersion 1.2.10 |
To Confirm the installation was a success we can use the following PowerShell command.
Get-Module -ListAvailable | where-Object {$_.Name -like "Azure*"} |
And that’s it you have now installed the Azure Stack PowerShell modules. In another blog post I will show you how to configure PowerShell for use with Azure Stack.
1 Comment
Register Azure Stack with your Azure Subscription – Pixel Robots. · August 31, 2017 at 7:03 pm
[…] Azure Subscription ID Username and Password of the Azure subscription owner The Azure Active Directory Name of the Azure subscription PowerShell For Azure Stack on Azure Stack host https://pixelrobots.co.uk/2017/07/install-the-azure-stack-powershell-module/ […]