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 / boxstarter.ps1
Created June 9, 2021 13:55 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@SQLDBAWithABeard
SQLDBAWithABeard / datacontroller.bicep
Last active May 26, 2021 10:54
bicepdatacontroller
// this is for a raw K8s installation
param name string
param customLocationName string
param tags object
param datacontrollerUserName string
@secure()
param datacontrollerPassword string
@secure()
@SQLDBAWithABeard
SQLDBAWithABeard / focusassisttoggle.ps1
Last active February 5, 2024 21:56
Focus Assist change with powershell hack
# Focus Assist Off
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait("(^{ESC})")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("(Focus Assist)")
Start-Sleep -Milliseconds 200
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep -Milliseconds 700
[System.Windows.Forms.SendKeys]::SendWait("{TAB}{TAB} ")
Start-Sleep -Milliseconds 500
@SQLDBAWithABeard
SQLDBAWithABeard / MI backup from errorlog.sql
Created January 18, 2021 11:42
Getting the MI backup info from error log
IF( SERVERPROPERTY('EngineEdition') = 8 )
BEGIN
/*
Description:
Script based on Dimitri Furman's dbo.sp_readmierrorlog procedure.
dbo.sp_readmierrorlog is a stored procedure that returns the contents of SQL Server and SQL Agent error logs on an MI instance.
The procedure filters out debug-level messages logged for service operation and troubleshooting purposes,
in order to make the error log more readable and actionable for MI users.
The procedure can be customized to add/remove specific filter strings.
@SQLDBAWithABeard
SQLDBAWithABeard / useful.ps1
Last active October 30, 2020 10:11
Useful scripts
#https://twitter.com/guyrleech/status/1322118170002468864
Start-Job -Name "Logoff when done" { sleep (("23:59 30/10/2020" -as [datetime]) - (date)).TotalSeconds ; logoff }
@SQLDBAWithABeard
SQLDBAWithABeard / gist:7685cb5ec70d74ed4188fe316d022e42
Last active July 27, 2020 18:00
Teams Notify Jobs - Success Failure last hour
$SQLInstances =
$webhookurl = ""
$startdate = (Get-Date).AddHours(-1)
Import-Module 'C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.107\dbatools.psd1'
$AllFailedJobs = foreach ($Instance in $SQLInstances) {
Write-Host "Connecting to $instance"
try{
@SQLDBAWithABeard
SQLDBAWithABeard / TeamsAllJobs.ps1
Last active July 27, 2020 17:59
notify teams agent results all jobs
$SQLInstances =
$startdate = (Get-Date).AddHours(-12)
$TeamsWebHook = ""
# Import-Module 'C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.107\dbatools.psd1'
$AllJobs = "
SqlInstance...|...Total...|...Successful...|...FailedJobs...|...FailedSteps...|...Canceled...
---------------------------------------------
"
foreach ($Instance in $SQLInstances) {
@SQLDBAWithABeard
SQLDBAWithABeard / update terraform.ps1
Created July 21, 2020 15:20
Updating terraform version
# based on https://github.com/guillermo-musumeci/terraform-update-version/blob/master/update-terraform.ps1
# Adding version so we dont get a beta version!
# download the page of Terraform releases
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$WebResponse = Invoke-WebRequest "https://releases.hashicorp.com/terraform"
# Version =
$Version = '0.12.28'
@SQLDBAWithABeard
SQLDBAWithABeard / using terraform locally.ps1
Created July 21, 2020 14:42
using azure SPN for local terraform state
## DO NOT SAVE THE tfvars file with values in it
## I have added them to a local key vault following this blog post https://sqldbawithabeard.com/2020/07/18/good-bye-import-clixml-use-the-secrets-management-module-for-your-labs-and-demos/
# This file will enable you to run terraform plan or import resources into terraform state locally
# You will need to create a directory called ignorevariables and copy the dev-backend-config.tfvars into it
<#
The dev-backend-config.tfvars file should look like this with the required values set for the environment you are using
1..100 | ForEach-Object {
$number = $Psitem
switch (($number % 5) -eq 0 -and ($number % 3 -eq 0)) {
$true { 'FizzBuzz' }
Default {
switch ($number % 3) {
0 { 'Fizz' }
Default {
switch ($number % 5) {
0 { 'Buzz' }