Skip to content

Instantly share code, notes, and snippets.

View DanielAdeniji's full-sized avatar

Daniel Adeniji DanielAdeniji

View GitHub Profile
@dkorobtsov
dkorobtsov / Add_WindowsDefender_Exclusions.ps1
Last active March 7, 2025 20:53
PowerShell script to add Windows Defender exclusions for WSL2 and JetBrains IDE performance issues
# PowerShell script to add Windows Defender exclusions for WSL2 and JetBrains IDE performance issues
#
# For context please read this thread:
# https://github.com/microsoft/WSL/issues/8995
#
# How to use?
# - Save the Script: Open a text editor like Notepad and paste the PowerShell script into it.
# - Save the file with a .ps1 extension, for example, Add_WindowsDefender_Exclusions.ps1.
# - Run PowerShell as Administrator: Search for "PowerShell" in the Start menu, right-click on it, and choose "Run as administrator".
# - Navigate to the Script's Location: Use the cd command to navigate to the directory where you saved the .ps1 file.
BEGIN TRANSACTION;
GO
CREATE TABLE [AspNetRoles] (
[Id] nvarchar(450) NOT NULL,
[Name] nvarchar(256) NULL,
[NormalizedName] nvarchar(256) NULL,
[ConcurrencyStamp] nvarchar(max) NULL,
CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
);
@spaghettidba
spaghettidba / testPFCLNT.ps1
Created August 26, 2019 14:54
Trace DLLs
#
# RUN THIS CODE IN Powershell x86 !!!!!
#
$dllPath = "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\PFCLNT.DLL"
$typeName = "Microsoft.SqlServer.Management.Trace.CTraceObjectsFileController"
try {
#
# this is the code found in Microsoft.SqlServer.Management.Trace.TraceFile.InitializeAsReader (thanks DotPeek...)
/*
* Creates an XEvent session utilizing the 'Trace' event added to SQL 2016
* This event will capture the protocol negotiation details of all TLS connections
* This allows you to capture how many connections are being made and with what
* protocol version and cipher.
* This information can be used to predict the impact of disabling a given
* protocol version or cipher suite before taking such actions.
*/
CREATE OR ALTER PROCEDURE usp_get_tls_connection_stats
@RulerOf
RulerOf / get-sshfingerprint.ps1
Created January 31, 2019 20:49
Get SSH host key fingerprint using PowerShell. Requires the WinSCP .Net assembly.
function Get-SshFingerprint {
param( [string]$ssh_server )
# Load WinSCP .NET assembly
Add-Type -Path "${env:ProgramFiles(x86)}\WinSCP\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = $ssh_server
@LitKnd
LitKnd / Execution-Cache-Single-Use-Plans-Explore.sql
Created January 31, 2017 17:50
TSQL to do a quick and dirty look at single-use plans in the execution plan cache of a SQL Server.
/***********************************************************
TSQL to do a quick and dirty look at single-use plans in
the execution plan cache of a SQL Server.
************************************************************/
/* Size of single use adhoc plans in execution plan cache */
SELECT
objtype,
cacheobjtype,
SUM(size_in_bytes)/1024./1024. as [MB]
@AlbertoMonteiro
AlbertoMonteiro / readme.md
Last active August 17, 2021 02:50
AWS Importing and Exporting SQL Server Databases
-- List enabled server specifications
SELECT audit_id,
a.name as audit_name,
s.name as server_specification_name,
d.audit_action_name,
s.is_state_enabled,
d.is_group,
d.audit_action_id,
s.create_date,
s.modify_date
@PeteGoo
PeteGoo / Send-UdpDatagram.ps1
Last active November 6, 2024 15:22
Sending UDP datagrams in powershell
function Send-UdpDatagram
{
Param ([string] $EndPoint,
[int] $Port,
[string] $Message)
$IP = [System.Net.Dns]::GetHostAddresses($EndPoint)
$Address = [System.Net.IPAddress]::Parse($IP)
$EndPoints = New-Object System.Net.IPEndPoint($Address, $Port)
$Socket = New-Object System.Net.Sockets.UDPClient
@sebastianwebber
sebastianwebber / generate_series.sql
Last active July 28, 2019 00:12
SQL Server generate_series
-- http://blog.jooq.org/2013/11/19/how-to-create-a-range-from-1-to-10-in-sql/
IF EXISTS (SELECT *
FROM dbo.sysobjects
WHERE id = object_id (N'[dbo].[generate_series]')
AND OBJECTPROPERTY(id, N'IsTableFunction') = 1)
DROP FUNCTION [dbo].[generate_series]
GO
CREATE FUNCTION [dbo].[generate_series] ( @p_start INT, @p_end INT)