Skip to content

Instantly share code, notes, and snippets.

View tcartwright's full-sized avatar

Tim Cartwright tcartwright

  • Houston, Texas
View GitHub Profile
@tcartwright
tcartwright / UpdateHelp.ps1
Last active November 8, 2022 15:42
POWERSHELL: Update-Help ignoring errors
# ignore update help exceptions, and just continue on updating help. throw the exception at the end if there was one
Update-Help -Force -ErrorAction Continue -ErrorVariable uhex
if ($uhex) {
throw $uhex.Exception
}
@tcartwright
tcartwright / CreateAppsJson.bat
Last active April 21, 2024 22:59
WINGET: MY winget installs
@rem bat file to ease use of the script
@%~d0
@cd "%~dp0"
winget export --output "%~dp0apps_temp.json" --accept-source-agreements
@tcartwright
tcartwright / ListWingetPackages.ps1
Last active November 11, 2022 15:15
POWERSHELL: Winget list all packages in alphabetical order
Clear-Host
# scanning winget is not perfect, but it allows you to get a list of packages avaialable from the winget store in alphabetical order.
# seems to have an issue with parsing non-english languages, possibly because of the unicode byte width
$includeUnicodeResults = $false #change this to include or exclude them from the results
$results = winget search --query `"`" |
Select-Object -Skip 3 |
ForEach-Object {
@tcartwright
tcartwright / ConfigureSplitTunneling.ps1
Last active January 23, 2024 15:00
POWERSHELL: Configure VPN
#Requires -RunAsAdministrator
Clear-Host
<#
AUTHOR: Tim Cartwright
Puprose: Turns on split tunneling for a VPN, and then adds all routes for the VPN. Subnets can be added or all A records from DNS
NOTES: Look for all parts with a "# CHANGE ME" comment, and change those to match your scenario
#>
@tcartwright
tcartwright / CertificatePolicy.ps1
Created September 2, 2022 16:51
POWERSHELL: Trust all server certs, and set TLS1.2
class TrustAllCertsPolicy : System.Net.ICertificatePolicy {
[bool] CheckValidationResult([System.Net.ServicePoint] $a,
[System.Security.Cryptography.X509Certificates.X509Certificate] $b,
[System.Net.WebRequest] $c,
[int] $d) {
return $true
}
}
[System.Net.ServicePointManager]::CertificatePolicy = [TrustAllCertsPolicy]::new()
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
@tcartwright
tcartwright / ScriptDatabaseFiles.md
Last active January 3, 2023 16:17
POWERSHELL: Script database into files
@tcartwright
tcartwright / AAA-MY-Red-Gate-Snippets.md
Last active August 15, 2025 13:36
My Red Gate Snippets

These are my Red Gate Snippets for use with SQL Prompt.

How to use:

  • The powershell file "PushSnippets.ps1" is used to update them.
  • It can be modified so as to push your own snippets once you create a GIST for them.
  • Read the instructions detailed in the powershell file
@tcartwright
tcartwright / generate_service_broker_notify.sql
Last active October 3, 2022 19:26
SQL SERVER: Generate a trigger that can be used to send service broker notifications
/*****MODIFY QUERY ************************/
DECLARE @TheQuery NVARCHAR(MAX) = '<PLACE YOUR QUERY HERE>'
/*****MODIFY QUERY ************************/
/**************************************************************/
-- DO NOT MODIFY BELOW THIS LINE
/**************************************************************/
SET NOCOUNT ON
@tcartwright
tcartwright / CaptureDeadlocks-Event.sql
Last active August 1, 2023 18:30
SQL SERVER: Capture deadlocks to a table
SET NOEXEC OFF;
GO
IF EXISTS (
SELECT 1
FROM [sys].[dm_xe_sessions]
WHERE [name] = 'Deadlock_Monitor'
) BEGIN
DROP EVENT SESSION [Deadlock_Monitor] ON SERVER;
RAISERROR(' Deadlock_Monitor Event Removed', 0, 1) WITH NOWAIT;
@tcartwright
tcartwright / SEND_SQL_ERROR_LOGS_TO_GRAYLOG_README.MD
Last active March 6, 2022 21:27
SQL SERVER: SQL Agent Job that ships error logs to GrayLog

This job is designed to send any new error logs to a Graylog server. Each time it runs the last date/time of the very last error in the log is recorded and is then used on the following run to only retrieve errors after the cut off date time.

TO USE:

  • Place the powershell in the desired directory
  • Edit the job sql with the appropriate directory and graylog server and port
  • Install the job using SQLCMD mode

OPTIONALLY: From a single server, you could loop a list of servers and call this powershell with each of the server names.