Useful Azure Powershell Commands

Get all the virtual networks in the subscription by using the following command.

 
azure network vnet list


You will need the Azure RM Powershell Modules installed on your system

# Install the Azure Resource Manager modules from the PowerShell Gallery
Install-Module AzureRM

Login-AzureRMAccount - Logs you into Azure RM
Login-AzureAccount - Logs you into Azure Classic

You can also login from variables:
$cred = Get-Credential
Login-AzureRmAccount -Credential $cred

# How to save your password to an encrypted text file
ConvertTo-SecureString -String "Password123" -AsPlainText -Force | ConvertFrom-SecureString | Set-Content "password.txt"
 
# You can also use a specific Tenant if you would like a faster log in experience
# Login-AzureRmAccount -TenantId xxxx
 
# To view all subscriptions for your account
Get-AzureRmSubscription

# To select a default subscription for your current session.
# This is useful when you have multiple subscriptions.
Get-AzureRmSubscription -SubscriptionName "your sub" | Select-AzureRmSubscription

# View your current Azure PowerShell session context
# This session state is only applicable to the current session and will not affect other sessions
Get-AzureRmContext

# To select the default storage context for your current session
Set-AzureRmCurrentStorageAccount -ResourceGroupName "your resource group" -StorageAccountName "your storage account name"

# View your current Azure PowerShell session context
# Note: the CurrentStorageAccount is now set in your session context
Get-AzureRmContext

# To list all of the blobs in all of your containers in all of your accounts
Get-AzureRmStorageAccount | Get-AzureStorageContainer | Get-AzureStorageBlob