Skip to content

Instantly share code, notes, and snippets.

@isjwuk
isjwuk / main.veeam.custom.role.tf
Last active August 20, 2026 16:49
Veeam Service Role Definition (Terraform)
# Create and Azure Custom Role with the required permissions for the Veeam service.
# Permissions from https://helpcenter.veeam.com/docs/vbr/userguide/azure_service_account_permissions.html?ver=13
resource "azurerm_role_definition" "veeam_service" {
name = "Veeam Service"
scope = data.azurerm_subscription.current.id
description = "Can perform actions required of Veeam Service Agent"
permissions {
actions = [
"Microsoft.Authorization/locks/delete",
"Microsoft.Authorization/locks/Read",
@isjwuk
isjwuk / vnet-extend-1.tf
Created March 24, 2026 15:06
Terraform to create 2 peered VNETs for a demo
###################### Resource Group ###################################################
# Create resource group
resource "azurerm_resource_group" "rg-routetest" {
name = "rg-vnet-extend-demo"
location = var.location
tags = var.tags
}
###################### VNET-1 ###################################################
@isjwuk
isjwuk / Update-MdeExtensionOnArcMachines.ps1
Last active January 12, 2026 14:49
PowerShell snippet which updates the Microsoft Defender for EndPoint Extension to the latest version on all the Windows Arc machines in the current Azure subscription
#Update the MDE Extension on all the Windows Arc machines in the current Azure subscription
#Get Latest Version of the MDE Extension (Change Region as appropriate)
$targetVersion= (Get-AzVMExtensionImage -Location "uksouth" -Type "MDE.Windows" -PublisherName "Microsoft.Azure.AzureDefenderForServers" | Sort-Object -Property Version -Descending | Select -First 1).Version
$Target=@{"Microsoft.Azure.AzureDefenderForServers.MDE.Windows" = @{"targetVersion"="$targetVersion"}}
#Loop through Arc Machines
ForEach ($Machine in Get-AzConnectedMachine){
#Get the MDE Extension if installed and not the current version
$MDEExtension=(Get-AzConnectedMachine -name $Machine.Name -ResourceGroupName $Machine.resourcegroupName).Resource | Where {$_.InstanceViewName -eq "MDE.Windows" -and $_.TypeHandlerVersion -ne $targetVersion}
@isjwuk
isjwuk / get-azvirtualnetworkdnsservers.ps1
Created December 23, 2025 08:50
Get DNS servers for all Azure VNETs
#Returns all the Azure VNETs along with their DNS servers
foreach ($subscription in Get-AzSubscription){
Set-AzContext $Subscription | Out-Null
Get-AzVirtualNetwork | Select-Object @{N="Subscription";E={$Subscription.Name}},
Name,
Location,
ResourceGroupName,
@{N="DnsServers";E={$_.DhcpOptions.DnsServers}}
}
@isjwuk
isjwuk / AzFirewallLogs.kql
Created October 10, 2024 14:39
Azure Firewall Logs KQL Query to format message field
AzureDiagnostics
| extend fromIP=tostring(split(split(msg_s,"from")[1],":")[0])
| extend toIP=tostring(split(split(msg_s,"to ")[1],":")[0])
| extend action= strcat(tostring(split(split(msg_s,"Action: ")[1],".")[0]), tostring(split(split(msg_s,"was ")[1],":")[0]) )
| extend rule= tostring(split(split(msg_s,"Rule: ")[1],":")[0])
| extend port= trim(":", tostring(split(split(msg_s,toIP)[1]," ")[0]))
| project TimeGenerated, fromIP, toIP, port, action, rule, msg_s
@isjwuk
isjwuk / Set-APIM-STV2-NSG-Rules.ps1
Created June 25, 2024 14:27
Set all the NSG Rules required for a stv2 instance of Azure API Management
Get-AzNetworkSecurityGroup -Name $Name -ResourceGroupName $ResourceGroupName `
| Add-AzNetworkSecurityRuleConfig -Name "ClientCommunicationtoAPIM" -Description "Client communication to API Management" -Access "Allow" -Protocol "tcp" -Direction "Inbound" -Priority 200 -SourceAddressPrefix "internet" -SourcePortRange "*" -DestinationAddressPrefix "VirtualNetwork" -DestinationPortRange (80,443) `
| Add-AzNetworkSecurityRuleConfig -Name "ManagementEndpointForAzurePortalAndPowerShell" -Description "Management endpoint for Azure portal and PowerShell" -Access "Allow" -Protocol "tcp" -Direction "Inbound" -Priority 210 -SourceAddressPrefix "ApiManagement" -SourcePortRange "*" -DestinationAddressPrefix "VirtualNetwork" -DestinationPortRange (3443) `
| Add-AzNetworkSecurityRuleConfig -Name "AzureInfrastructureLoadBalancer" -Description "Azure Infrastru
@isjwuk
isjwuk / Get-AzVMsWithNoImage
Created July 3, 2023 15:47
Get Azure VMs with no marketplace image
# Get Azure VMs with no marketplace image
Get-AzVm | Where-Object {!($_.StorageProfile.ImageReference)}
@isjwuk
isjwuk / gist:8480669a383f5ea894a00a2b677446a2
Created May 18, 2023 14:22
Nginx Web Server config to redirect subpage to subpage.html
#Redirect example.com/subpage1 to example.com/subpage1.html, example.com/subpage2 to example.com/subpage2.html
#And so on
#Snippet from the nginx config file
#Tested in an Azure PHP WebApp
#Redirect /page to /page.html
location / {
try_files $uri $uri/index.html $uri/index.php $uri.html $uri/ ;
}
@isjwuk
isjwuk / Get-AzEmptyAppServicePlans.ps1
Created January 30, 2023 09:37
Find Azure App Service Plans with no App Services associated with them.
<#
.SYNOPSIS
Find empty Azure App Service Plans
.DESCRIPTION
Find Azure App Service Plans in the current Azure Context with no App Services associated with them.
These empty App Service Plans will potentially be incurring unneccessary charges.
.EXAMPLE
#Return a list of Empty App Service Plans in the current Azure Context
Get-AzEmptyAppServicePlans
.EXAMPLE
@isjwuk
isjwuk / Get-AzVMsNotBackedUp.ps1
Last active August 22, 2022 19:16
Return a List of Azure VMs not backed up by Recovery Services Vaults
#Return a List of Azure VMs (in the current context) which are not backed up by Recovery Services Vaults
$BackupStatus=@()
$BackupStatus=foreach ($VM in Get-AzVM) { $VM | Select-Object Name, ResourceGroupName, @{Name="BackedUp";Expression={(Get-AzRecoveryServicesBackupStatus -Name $VM.Name -ResourceGroupName $VM.ResourceGroupName -Type AzureVM).BackedUp }}}
$BackupStatus | Where {$_.BackedUp -eq $false} | Select Name, ResourceGroupName