Get Azure Networking Hierarchy Components With Powershell

| Sep 16, 2019

I needed to see what VNETs, their subnets and the NIC/IPs attached to those subnets which is all available in Azure Portal but I wanted a nice hierarchical listing so here is a Powershell script for that…

$vnets = Get-AzVirtualNetwork
foreach ($vnet in $vnets)
"VNET: " + $vnet.Name
"Subnet Count: " + $vnet.Subnets.count
foreach ($subnet in $vnet.Subnets)
"..Subnet: " + $subnet.Name
if ($Subnet.IpConfigurations.count -eq 0)

Azure Advisor And Fixing Errors

| Sep 9, 2019

Azure can be configured to send you advisor reports detailing things that are not quite right in your environment. The advisor is not necessarily always right but it’s sensible to review the outputs periodically, even if they relate to non production environments.

A few issues popped up on an advisor report on my recent travels and although you can just use the entries on the report on the portal to target the offending resources, I (more...)

Finding databases on each SQL Server using Powershell

| Sep 7, 2019

A client had the requirement to list out the SQL Servers and the databases they have installed on those SQL Servers in their Azure Cloud environment this week. The reason for the requirement was to find SQL Servers that no longer had any databases on them so they could be considered for removal.

Essentially, it gathers a list of SQL Server resources, loops through them and counts and itemises them, not including the master database (more...)

Azure Active Directory (AAD)

| Sep 3, 2019

Find the ID of an existing user:

PS Azure:> $azureaduser=$(az ad user list --filter "userPrincipalName eq ''" --query [].objectId --output tsv)


PS Azure:> $azureaduser


Show all users in AAD:

az ad user list --query [].userPrincipalName

Virtual Machines (VMs)

| Sep 1, 2019

Getting an Image

Get-AzureRmVMImagePublisher -Location $Location
Get-AzureRmVMImageOffer -Location $Location -PublisherName "MicrosoftSQLServer"
Get-AzureRmVMImageSku -Location $Location -PublisherName "MicrosoftSQLServer" -Offer "SQL2019-WS2016"
Get-AzureRmVMImage -Location $Location -PublisherName "MicrosoftSQLServer" -Offer "SQL2019-WS2016" -Skus "SQLDEV"


| Aug 29, 2019

Show tags for all resources

az group list --query [].tags 

Create tag

az tag create --name "Review Date"

Create tag with values

az tag add-value --name Environment --value Development

Set a tag to a value for a resource group

az group update -n example-resource-group --set tags.Environment=prod tags.CostCenter=IT