Skip to content

Instantly share code, notes, and snippets.

@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
#Create Resources for testing AZCopy in a Web App
#See https://isjw.uk/post/azure/azure-app-service-azcopy/
#Creates an Azure Resource Group containing an App Service Plan, a Web App, and a Storage Account.
#Set some parameters
$location="NorthEurope"
$resourceGroupName= "azcopytest-rsg"
$webAppName="azcopytest-web"
$appServicePlanName="azcopytest-asp"
$storageAccountName=("azcopyteststo"+((New-Guid) -replace ("-",""))).Substring(0,20)
@isjwuk
isjwuk / DefaultResourceGroupLocation.ps1
Created February 8, 2022 20:19
Set a default location for Azure Resource Groups
#Set the default location for new resource groups.
$PSDefaultParameterValues.Add("New-AzResourceGroup:Location","uksouth")
#Create a Resource Group without specifying the location parameter
New-AZResourceGroup -Name "test-rsg"
@isjwuk
isjwuk / Get-ESXiHostDetails.ps1
Created January 24, 2022 09:19
Get the Vendor, Model, and Serial Number of ESXi hosts
Get-VMHost | Select-Object Name, `
@{Name="Vendor";E={$_.ExtensionData.Hardware.SystemInfo.Vendor}}, `
@{Name="Model";E={$_.ExtensionData.Hardware.SystemInfo.Model}}, `
@{Name="SerialNumber";E={$_.ExtensionData.Hardware.SystemInfo.SerialNumber}} `
| Sort-Object -Property Name