Skip to content

Instantly share code, notes, and snippets.

@smoonlee
smoonlee / Invoke-AppGwAudit.ps1
Last active July 7, 2025 10:35
Audit Application Gateway Limits
# Azure Application Gateway Resource Usage Audit Script
# This script checks the resource usage of Application Gateways against their limits
# Function to format numbers as percentages
function Format-AsPercentage {
param([int]$current, [int]$maximum)
if ($maximum -eq 0) { return "N/A" }
return "{0:P0}" -f ($current / $maximum)
}
@smoonlee
smoonlee / isnullempty.ps1
Created March 12, 2025 08:53
Powershell - IsNullEmpty
([string]::IsNullOrEmpty($version))
@smoonlee
smoonlee / share-buttons.html
Created December 4, 2024 18:22
Hugo Social Media Share Buttons
{{/* Made using https://sharingbuttons.io/ */}}
{{ if not .Params.disableShare }}
{{ if (not (isset .Site.Params.ShareButtons "size")) }}
{{ errorf "'size' should be specified inside shareButtons in hugo config file" }}
{{ end }}
{{ $possibleSizes := (slice "small" "medium" "large") }}
{{ if not (in $possibleSizes .Site.Params.ShareButtons.Size) }}
{{ errorf "'size' is %q but should be set to one of possible sizes: %q " .Site.Params.ShareButtons.Size (delimit $possibleSizes ", ") }}
@smoonlee
smoonlee / azure-shortcode-location.ps1
Created October 21, 2024 08:15
Pwsh locationShortCode switch
# Azure Location ShortCode Switch
switch ($location) {
'eastus' { $locationShortCode = 'eus' }
'eastus2' { $locationShortCode = 'eus2' }
'westus' { $locationShortCode = 'wus' }
'westus2' { $locationShortCode = 'wus2' }
'northcentralus' { $locationShortCode = 'ncus' }
'southcentralus' { $locationShortCode = 'scus' }
'centralus' { $locationShortCode = 'cus' }
'canadacentral' { $locationShortCode = 'cc' }
@smoonlee
smoonlee / action-install-hugo-windows.yaml
Created October 6, 2024 10:55
Download and install Hugo.Extended (Windows)
name: Hugo Check and Install (Windows)
on:
push:
branches:
- main
workflow_dispatch:
# Uncomment the following lines if you want to add pull request triggers
# pull_request:
# types: [opened, synchronize, reopened, closed]
@smoonlee
smoonlee / action-install-hugo-linux.yaml
Created October 6, 2024 10:55
Download and install Hugo.Extended (Linux)
name: Hugo Check and Install (Linux)
on:
push:
branches:
- main
workflow_dispatch:
# Uncomment the following lines if you want to add pull request triggers
# pull_request:
# types: [opened, synchronize, reopened, closed]
$wc = New-Object net.webclient
$wc.Downloadfile($video_url, $local_video_url)
function Get-UsableAddressSpace {
param (
[Parameter(Mandatory = $true)]
[string]$CIDR
)
# Function to convert IP address to integer
function ConvertTo-Int {
param ($ip)
$i = 0
@smoonlee
smoonlee / Get-AzSystemUptime
Last active May 6, 2024 20:09
Get Uptime for Linux and Windows machines in Azure
# Function - Get Azure Virtual Machine System Uptime
function Get-AzSystemUptime {
param (
[string] $subscriptionId,
[string] $resourceGroup,
[string] $vmName
)
if ($subscriptionId) {
Set-AzContext -SubscriptionId $subscriptionId | Out-Null
@smoonlee
smoonlee / ubuntu-linux-virtual-installer.sh
Created March 29, 2024 16:58
Hyper-V Ubuntu Virtual Kernel Setup script
#!/bin/bash
# Microsoft Hyper-V Intergration Services (Ubuntu/Debian Install Script)
# Author: Simon Lee
# Script Revision: 1.0
# Description: Install linux-virtual kernal for Ubuntu/Debian Server
# Clear Current Screen
clear
# Check Session Status