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 / Search-AzureDevOpsCode.ps1
Last active October 14, 2023 01:29
PowerShell script to find code in Azure DevOps service
View Search-AzureDevOpsCode.ps1
#requires -Version 7.2
Azure DevOps REST API to get a results across an organization based on provided search text, just as you would in the web UI
Based on provided answer from SO:
./Search-AzureDevOpsCode.ps1 -OrganizationName Company -Project Enterprise -SearchFilter "ext:yml AND somestringvalue" -AzAccessToken (Get-AzAccessToken)
wsmelton / docker-compose
Created September 6, 2023 13:55
Initialize SQL Server containers via Docker compose
View docker-compose
version: '3.7'
container_name: 'sql17'
platform: linux/amd64
wsmelton / Get-AzComputeResourceDetails.ps1
Created September 20, 2022 14:25
Get the compute resource details for VM and Disk into an Excel file
View Get-AzComputeResourceDetails.ps1
#Requires -Modules ImportExcel, Az.Accounts, Az.Compute
Retrieve region specific Sku details for Virtual Machines and Managed Disks into an Excel file
./Get-AzComputeResourceData.ps1 -Regions 'westus2','westus3' -ExcelFileName 'c:\temp\azComputeResourceSku.xlsx
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+
View Find-AppRegistrationExpiringSecrets.ps1
#requires -Module Az.Resources
#requires -Version 7
Based on Get-AppRegistrationExpiration by Cj-Scott
$applications = Get-AzADApplication | Where-Object { $_.KeyCredentials.DisplayName -gt 0 }
$today = (Get-Date).ToUniversalTime()
wsmelton / Get-AzRegionZone.ps1
Created April 19, 2022 20:54
Get a list of Zones available in a given Azure Region
View Get-AzRegionZone.ps1
$subObj = Get-AzSubscription -SubscriptionName $SubscriptionName
Set-AzContext -SubscriptionObject $subObj
$payload = @{
location = $location
subscriptionIds = @("subscriptions/$($subObj.Id)")
View Get-ClusterNetworkFQDN.ps1
$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 / Find-MissingCommands.ps1
Last active December 31, 2021 19:54
Commands index page comparison to Commands in dbatools module (cmdlet and function)
View Find-MissingCommands.ps1
function Find-MissingCommands {
Find missing commands between the and dbatools Module public functions
Path to dbatools local repository
.PARAMETER CommandPagePath
Full path to the index.html commands page (e.g. c:\git\web\commands\index.html)
View current_profile.ps1
#$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
wsmelton /
Last active July 21, 2021 20:12
A look into the parameters of Copy-DbaLogin

SQL Server migrations, the bain in most DBA's lives when they find out one is coming up. At that top of the list, along with finding out, you need to test your database DR strategy that is fully documented 😉 😉.

Still, one of the most common tasks that can be in day-to-day activity is getting logins created between various SQL Server instances. Say you have to support multiple environments for a given application database, creating that login 3, 4, 5 different times manually using SSMS 😧! dbatools includes a ton of commands that help in migrations.

Do you have multiple Availability Groups (AG) deployed in your environment? AGs that have 3, 4, 6 replicas that you are adding a login to one require adding it to all the other replicas?

These scenarios, among many others, are where Copy-DbaLogin can help make your life easier and give you more time to catch up on other things.


wsmelton / module.FileIntegrity.tests.ps1
Last active October 29, 2020 00:53
Pester 5 File Integrity Tests using 5.1 version of Pester
View module.FileIntegrity.tests.ps1
$moduleRoot = (Resolve-Path "$PSScriptRoot\..").Path
$allFiles = Get-ChildItem -Path $moduleRoot -Recurse -Filter "*.ps1" |
Where-Object FullName -NotLike "$moduleRoot\tests\*" |
Where-Object FullName -NotLike "$moduleRoot\Build.ps1"
Describe "Verifying module PS1 files" -Foreach $allFiles {
BeforeAll {
$name = $_.Name
$fullName = $_.FullName
$file = $_