Working with PowerShell

If your work is not GUI-based, PowerShell could be your friend. You can set up your computer by installing Azure Stack PowerShell upon Azure PowerShell by running the following commands:

  1. Install Azure PowerShell (in PowerShell evaluated admin mode):
install-module AzureRM

  1. Install Azure Stack PowerShell (in PowerShell evaluated admin mode):
Import-Module -Name PowerShellGet -ErrorAction Stop
Import-Module -Name PackageManagement -ErrorAction Stop
Get-PSRepository -Name "PSGallery"
Register-PsRepository -Default
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
# Install the AzureRM.Bootstrapper module. Select Yes when prompted to install NuGet
Install-Module -Name AzureRm.BootStrapper
# Install and import the API Version Profile required by Azure Stack into the current PowerShell session.
Use-AzureRmProfile -Profile 2018-03-01-hybrid -Force
Install-Module -Name AzureStack -RequiredVersion 1.5.0

As an example, let's have a look at how to create a storage resource using PowerShell:

# Create variables to store the storage account name and the storage account SKU information
$StorageAccountName = "mystorageaccount"
$SkuName = "Standard_LRS"

# Create a new storage account
$StorageAccount = New-AzureRMStorageAccount `
-Location $location `
-ResourceGroupName $ResourceGroupName `
-Type $SkuName `
-Name $StorageAccountName
Set-AzureRmCurrentStorageAccount `
-StorageAccountName $storageAccountName `
-ResourceGroupName $resourceGroupName

# Create a storage container to store a virtual machine image
$containerName = 'osdisks'
$container = New-AzureStorageContainer `
-Name $containerName `
-Permission Blob

Everything is possible through PowerShell, so the following link may help to dive deeper into Azure Stack PowerShell: https://docs.microsoft.com/en-us/azure/azure-stack/user/azure-stack-quick-create-vm-windows-powershell.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.76.164