Skip to content

Instantly share code, notes, and snippets.

Little bit of this, little bit of that

Shawn Melton wsmelton

Little bit of this, little bit of that
View GitHub Profile
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 = $_
wsmelton / thycotic_terminal_theme.json
Created September 22, 2020 23:30
Thycotic Theme for Windows Terminal
View thycotic_terminal_theme.json
"name": "thycotic",
// entire background
"background": "#081F2C",
// default text
"foreground": "#B3D565",
//quoted values
"cyan": "#3CC4E5",
// commands
"brightYellow": "#80BB01",
wsmelton / ignoreCertPolicy.ps1
Created August 17, 2020 14:06
Working with sites that have untrusted cert for site, where CA may not be accessible, etc.
View ignoreCertPolicy.ps1
if (-not("dummy" -as [type])) {
add-type -TypeDefinition @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public static class Dummy {
public static bool ReturnTrue(object sender,
X509Certificate certificate,