Skip to content

Latest commit

 

History

History
147 lines (101 loc) · 7.85 KB

azs-how-configure-powershell-users.md

File metadata and controls

147 lines (101 loc) · 7.85 KB
title description services author reviewer lastreviewed toc_rootlink toc_sub1 toc_sub2 toc_sub3 toc_sub4 toc_title toc_fullpath toc_mdlink
How to configure the Azure Stack Hub user's PowerShell environment
Configure the Azure Stack Hub user's PowerShell environment
azure-stack
cblack
wturner
08/12/2021
Users
How To
Configure Environment
Configure the Azure Stack Hub user's PowerShell environment
Users/How To/azs-how-configure-powershell-users.md
azs-how-configure-powershell-users.md


UKCloud Limited (“UKC”) and Virtual Infrastructure Group Limited (“VIG”) (together “the Companies”) – in Compulsory Liquidation

On 25 October 2022, the Companies were placed into Liquidation with the Official Receiver appointed as Liquidator and J Robinson and A M Hudson simultaneously appointed as Special Managers to manage the liquidation process on behalf of the Official Receiver.

Further information regarding the Liquidations can be found here: https://www.gov.uk/government/news/virtual-infrastructure-group-limited-and-ukcloud-limited-information-for-creditors-and-interested-parties

Contact details:
For any general queries relating to the Liquidations please email ukcloud@uk.ey.com
For customer related queries please email ukcloudcustomers@uk.ey.com
For supplier related queries please email ukcloudsuppliers@uk.ey.com

How to configure the Azure Stack Hub user's PowerShell environment

As an Azure Stack Hub user, you can use PowerShell to manage Azure Stack Hub resources such as create virtual machines, deploy Azure Resource Manager templates, etc. This topic is scoped to use with the user environments only. In order to interact with Azure Stack Hub PowerShell, you will need to set up your environment. To do so follow the below guide:

Prerequisites

Prerequisites from a Windows-based external client.

  • PowerShell 5.1

    [!NOTE] To check your version, run $PSVersionTable.PSVersion and compare the "Major" version.

    For "legacy" operating systems such as Windows Server 2008 R2, Windows 7, Windows Server 2012, Windows Server 2012 R2 and Windows 8.1 you will need to download the Windows Management Framework 5.1

Declare variables

Enter details below to provide values for the variables in the scripts in this article:

Variable name Variable description Input
$ArmEndpoint The Azure Resource Manager endpoint for Azure Stack Hub
$AzsUsername Your AAD username
$AzsPassword Your AAD password

Install Azure Stack Hub PowerShell

# Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# PowerShell commands for Azure Stack Hub are installed through the PSGallery repository
# To register the PSGallery repository, open an elevated PowerShell session and run the following command:
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

# Install the latest version of PowerShellGet
Install-Module -Name PowerShellGet -Force

Close and reopen your elevated PowerShell session to load the newly installed version of the PowerShellGet module.

# Uninstall existing versions of Azure/Azure Stack Hub PowerShell
Get-Module -Name Azs.*, Azure*, Az.* -ListAvailable | Uninstall-Module -Force -Verbose

# On some older systems, you may need to explicitly set the TLS 1.2 security protocol to be able to interact with PowerShell Gallery
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Install the Az.BootStrapper module
Install-Module -Name Az.BootStrapper -Force

# Install and import the API Version Profile required by Azure Stack Hub into the current PowerShell session
Install-AzProfile -Profile 2020-09-01-hybrid -Force
Install-Module -Name AzureStack -RequiredVersion 2.2.0

# Confirm the installation
Get-Module -Name "Az*" -ListAvailable
Get-Module -Name "Azs*" -ListAvailable

Configure the user environment and sign in to Azure Stack Hub

Azure Active Directory (AAD) based deployments

# Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# Declare endpoint
$ArmEndpoint = "https://management.frn00006.azure.ukcloud.com"

# Register an Az environment that targets your Azure Stack Hub instance
Add-AzEnvironment -Name "AzureStackUser" -ArmEndpoint $ArmEndpoint

# Sign in to your environment
Connect-AzAccount -EnvironmentName "AzureStackUser"

Azure Active Directory (AAD) based deployments - Embedded Credentials

Warning

This method will not work if multi-factor authentication is required for your AAD account. You must use the other method that does not have the -Credential parameter on the Connect-AzAccount cmdlet.

# Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# Declare endpoint
$ArmEndpoint = "https://management.frn00006.azure.ukcloud.com"

# Register an Az environment that targets your Azure Stack Hub instance
Add-AzEnvironment -Name "AzureStackUser" -ArmEndpoint $ArmEndpoint

# Create your Credentials
$AzsUsername = "user@contoso.onmicrosoft.com"
$AzsPassword = 'Password123!'
$AzsUserPassword = ConvertTo-SecureString -String $AzsPassword -AsPlainText -Force
$AzsCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AzsUsername, $AzsUserPassword

# Sign in to your environment
Connect-AzAccount -Credential $AzsCred -EnvironmentName "AzureStackUser"

Test the connectivity

Now that we've got everything set-up, let's use PowerShell to create resources within Azure Stack Hub. For example, you can create a resource group for an application and add a virtual machine. Use the following command to create a resource group named "MyResourceGroup":

# Get location of Azure Stack Hub
$Location = (Get-AzLocation).Location

New-AzResourceGroup -Name "MyResourceGroup" -Location $Location

Next steps

Feedback

If you find a problem with this article, click Improve this Doc to make the change yourself or raise an issue in GitHub. If you have an idea for how we could improve any of our services, send an email to feedback@ukcloud.com.