Skip to content

Instantly share code, notes, and snippets.

View SQLDBAWithABeard's full-sized avatar
🦄
Generally bearding

Rob Sewell SQLDBAWithABeard

🦄
Generally bearding
View GitHub Profile
@SQLDBAWithABeard
SQLDBAWithABeard / remove-filesystemitem.ps1
Last active April 11, 2024 16:02
cant remove unempty dorectories
function Remove-FileSystemItem {
<#
.SYNOPSIS
Removes files or directories reliably and synchronously.
.DESCRIPTION
Removes files and directories, ensuring reliable and synchronous
behavior across all supported platforms.
The syntax is a subset of what Remove-Item supports; notably,
@SQLDBAWithABeard
SQLDBAWithABeard / rough-k8s-backup.ps1
Last active December 6, 2023 11:39
rough-k8s-backup
$resources = (kubectl api-resources --namespaced=$true 2>$null | Where-Object { $_ -notmatch "events" } | Select-Object -Skip 1 | ForEach-Object { $_.Split()[0] })
$output_folder = 'C:\temp\K8s-output'
if(!(Test-Path $output_folder)) {
New-Item $output_folder -ItemType Directory | Out-Null
}
foreach($resource in $resources){
@SQLDBAWithABeard
SQLDBAWithABeard / prompt.ps1
Created May 2, 2023 08:27
Random OhMyPosh prompt :-)
function Load-Profile {
$env:POSH_THEMES_PATH = '{0}\Programs\oh-my-posh\themes' -f $env:LOCALAPPDATA
function global:Set-PoshPrompt {
param(
$theme
)
& oh-my-posh.exe init pwsh --config "$env:POSH_THEMES_PATH\$theme.omp.json" | Invoke-Expression
}
@SQLDBAWithABeard
SQLDBAWithABeard / linux-badge.svg
Last active March 26, 2024 14:13
dbachecks status badges
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / Trace-AICommand.ps1
Created June 27, 2022 09:15 — forked from JustinGrote/Trace-AICommand.ps1
Report the results and performance of any scriptblock to Azure Application Insights
#requires -version 7
#You can load this script with $(iwr https://tinyurl.com/TraceAICommand | iex)
using namespace Microsoft.ApplicationInsights
using namespace Microsoft.ApplicationInsights.Extensibility
using namespace Microsoft.ApplicationInsights.DataContracts
using namespace System.Management.Automation
using namespace System.Collections.Generic
using namespace System.Net
#Reference: https://docs.microsoft.com/en-us/azure/azure-monitor/app/console
@SQLDBAWithABeard
SQLDBAWithABeard / ResourcesWithNoTagsFix.ps1
Last active May 30, 2022 12:17
To show some Azure Graph things
$rgwithwrongtags = $results #| where resourcebilling -eq 'somedefaultvalue'
$count = $rgwithwrongtags.Count
foreach ($resource in $rgwithwrongtags) {
$context = Get-AzContext
$excludedtypes = 'microsoft.compute/virtualmachines/extensions','microsoft.network/privatednszones/virtualnetworklinks','microsoft.network/privatednszones'
if ($resource.type -notin $excludedtypes) {
Set-BillingTag -resource $resource -billingtag $resource.rgbilling
}
else {
@SQLDBAWithABeard
SQLDBAWithABeard / Apollo 13, 1995
Last active May 27, 2022 12:07
SQL 2022 Contained
Houston, we have a problem.
You will need to add the link to the 2022 container when it is available to the docker compose file
@SQLDBAWithABeard
SQLDBAWithABeard / Get-MicrosoftTags.ps1
Last active May 27, 2022 15:25
get microsoft tags
function Get-MicrosoftTags {
$AllRepos = (iwr https://mcr.microsoft.com/v2/_catalog).content | ConvertFrom-Json
# $AllRepos.Repositories | where{ $_ -like '*sql*'}
if ($IsCoreCLR) {
$repo = $AllRepos.Repositories | Out-ConsoleGridView -OutputMode Single
}
else {
$repo = $AllRepos.Repositories | Out-GridView -Passthru
}
$Url = "https://mcr.microsoft.com/v2/{0}/tags/list" -f $repo
@SQLDBAWithABeard
SQLDBAWithABeard / powershell.json
Last active October 8, 2021 18:09
powershell vscode snippets
{
/*
These are PowerShell snippets which you can use in Visual Studio Code
To use them click File --> Preferences --> User Snippets and type PowerShell
or edit $env:\appdata\code\user\snippets\powershell.json
In general and in order I converted exisitng snippets like this
Replace `$ with $$
Replace \ with \\
Replace " with \"
\r for new line
@SQLDBAWithABeard
SQLDBAWithABeard / whatschanged.yaml
Last active August 10, 2021 03:04
azure repo which files have changed
- task: AzurePowerShell@5
displayName: Deploy Changes
inputs:
azureSubscription: ''
ScriptType: 'InlineScript'
Inline: |
# Get the changes for the current build
$webClient = New-Object Net.WebClient
$token = "Bearer $env:SYSTEM_ACCESSTOKEN"
$headers = @{ Authorization = $token }