Skip to content

Instantly share code, notes, and snippets.

View wsmelton's full-sized avatar
🦆
Little bit of this, little bit of that

Shawn Melton wsmelton

🦆
Little bit of this, little bit of that
View GitHub Profile
@wsmelton
wsmelton / aks-pool-updates
Last active February 10, 2026 14:10
Pull the activity log for AKS agent pool updates/writes
AzureActivity
| where TimeGenerated >= ago(15d)
and OperationNameValue == "Microsoft.ContainerService/managedClusters/agentpools/write"
| project TimeGenerated, Level, CorrelationId, EventSubmissionTimestamp, ActivityStatusValue, Properties_d.message, Properties_d.resource
@wsmelton
wsmelton / Get-AzResourceCreateDate.ps1
Created April 11, 2025 15:46
Get the created date of a resources in a Resource Group in Azure
[cmdletbinding()]
param(
[string]$ResourceGroupName
)
$context = Get-AzContext
$subName = $context.Subscription.Name
$subId = $context.Subscription.Id
if ($ResourceGroupName) {
$uri = "/subscriptions/$($subId)/resourceGroups/$($ResourceGroupName)/resources?`$expand=createdTime&api-version=2021-04-01"
@wsmelton
wsmelton / Search-AzureDevOpsCode.ps1
Last active June 7, 2024 09:48
PowerShell script to find code in Azure DevOps service
#requires -Version 7.2
<#
.SYNOPSIS
Azure DevOps REST API to get a results across an organization based on provided search text, just as you would in the web UI
.NOTES
https://learn.microsoft.com/en-us/rest/api/azure/devops/search/code-search-results/fetch-code-search-results?view=azure-devops-rest-7.1&tabs=HTTP#coderesult
Based on provided answer from SO: https://stackoverflow.com/a/64973447/12974596
.EXAMPLE
./Search-AzureDevOpsCode.ps1 -OrganizationName Company -Project Enterprise -SearchFilter "ext:yml AND somestringvalue" -AzAccessToken (Get-AzAccessToken)
@wsmelton
wsmelton / docker-compose
Created September 6, 2023 13:55
Initialize SQL Server containers via Docker compose
version: '3.7'
services:
sql17:
container_name: 'sql17'
platform: linux/amd64
image:
mcr.microsoft.com/mssql/server:2017-latest
environment:
@wsmelton
wsmelton / Get-AzComputeResourceDetails.ps1
Created September 20, 2022 14:25
Get the compute resource details for VM and Disk into an Excel file
#Requires -Modules ImportExcel, Az.Accounts, Az.Compute
<#
.SYNOPSIS
Retrieve region specific Sku details for Virtual Machines and Managed Disks into an Excel file
.EXAMPLE
./Get-AzComputeResourceData.ps1 -Regions 'westus2','westus3' -ExcelFileName 'c:\temp\azComputeResourceSku.xlsx
#>
[cmdletbinding()]
param(
@wsmelton
wsmelton / Find-AppRegistrationExpiringSecrets.ps1
Created August 31, 2022 16:53
Use Az.Resources commands to pull App Registrations' Client Secret expiration status from Azure AD - Requires PowerShell 7+
#requires -Module Az.Resources
#requires -Version 7
<#
.SYNOPSIS
Based on Get-AppRegistrationExpiration by Cj-Scott
https://github.com/Cj-Scott/Get-AppRegistrationExpiration
#>
$applications = Get-AzADApplication | Where-Object { $_.KeyCredentials.DisplayName -gt 0 }
$today = (Get-Date).ToUniversalTime()
@wsmelton
wsmelton / Get-AzRegionZone.ps1
Created April 19, 2022 20:54
Get a list of Zones available in a given Azure Region
param(
[string]$Location,
[string]$SubcriptionName
)
$subObj = Get-AzSubscription -SubscriptionName $SubscriptionName
Set-AzContext -SubscriptionObject $subObj
$payload = @{
location = $location
subscriptionIds = @("subscriptions/$($subObj.Id)")
[cmdletbinding()]
param(
[string]
$VMName
)
$scriptBlock = {
$clusterNetworkNames = Get-ClusterResource | Where-Object ResourceType -eq 'Network Name'
foreach ($n in $clusterNetworkNames) {
if ($n.Name -match 'SQL Network Name') {
$hostValue = $n.Name.TrimStart('SQL Network Name (').TrimEnd(')')
@wsmelton
wsmelton / Find-MissingCommands.ps1
Last active December 31, 2021 19:54
Commands index page comparison to Commands in dbatools module (cmdlet and function)
function Find-MissingCommands {
<#
.SYNOPSIS
Find missing commands between the dbatools.io/commands and dbatools Module public functions
.PARAMETER ModulePath
Path to dbatools local repository
.PARAMETER CommandPagePath
Full path to the index.html commands page (e.g. c:\git\web\commands\index.html)
#$PSDefaultParameterValues = @{ "*:Credential" = (Get-Secret username) }
if ($psedition -ne 'Core') {
[System.Net.ServicePointManager]::SecurityProtocol = @("Tls12", "Tls11", "Tls", "Ssl3")
}
function Prompt {
$major = $PSVersionTable.PSVersion.Major
$minor = $PSVersionTable.PSVersion.Minor
$patch = $PSVersionTable.PSVersion.Patch
if ($major -lt 6) {
Write-Host "[PS $($major).$($minor)] [" -NoNewline