Skip to content

Instantly share code, notes, and snippets.

Avatar
🕵️‍♂️
Figuring it out

Eitan Blumin EitanBlumin

🕵️‍♂️
Figuring it out
View GitHub Profile
@EitanBlumin
EitanBlumin / zendesk_set_primary_and_secondary_sla.ps1
Created Apr 24, 2018
Zendesk API - Set Primary and Secondary Talk Agents and Availability
View zendesk_set_primary_and_secondary_sla.ps1
param
(
[string] $PrimaryNinja = "Jane Doe",
[string] $SecondaryNinja = "John Smith"
)
$global:zendesk_user_name = "myaccount@mydomain.com/token" # The /token part is obligatory when using Zendesk's API
$global:zendesk_password = "put_your_zendesk_API_token_here"
$global:zendesk_address = "https://your_zendesk_subdomain_here.zendesk.com"
$global:primarySLAgroupname = "SLA Primary"
@EitanBlumin
EitanBlumin / Find_SQL_TCP_Port.sql
Last active May 7, 2018
Find SQL Server Instance TCP Port In Use
View Find_SQL_TCP_Port.sql
USE master
GO
-- Using SQL Error Logs:
xp_readerrorlog 0, 1, N'Server is listening on', N'any', NULL, NULL, N'asc'
-- will also return records for DB Mirroring endpoints
-- also, this won't work if error log was cycled
GO
-- Using currently connected connections:
@EitanBlumin
EitanBlumin / Check_SQLServerUpdates.ps1
Created May 7, 2018
Check For SQL Server Updates Using SQLServerUpdatesModule
View Check_SQLServerUpdates.ps1
param (
[version] $BuildNumber = "9.00.5324"
)
#Run this script with -ExecutionPolicy Bypass
Install-Module -Name SQLServerUpdatesModule
Import-Module SQLServerUpdatesModule
$ErrorActionPreference = "SilentlyContinue"
@EitanBlumin
EitanBlumin / zendesk_change_ticket_status.ps1
Created May 7, 2018
Change Zendesk Ticket Status Using Powershell
View zendesk_change_ticket_status.ps1
param
(
[int] $ticketid,
[validateset ("new","open","pending","solved","closed","delete","same")] [string] $newstatus,
[string] $admincomment = ""
)
# Global Zendesk Settings:
$global:zendesk_address = "https://yourcompany.zendesk.com"
@EitanBlumin
EitanBlumin / DeadlockTrace_Info.sql
Last active Jun 25, 2018
Get Deadlock Trace Info from Default Trace
View DeadlockTrace_Info.sql
declare @filename nvarchar(200)
select @filename = convert(nvarchar(200), value)
from ::fn_trace_getinfo(null)
where property = 2
and convert(nvarchar(200), value) LIKE '%deadlocks%'
PRINT @filename
select StartTime, convert(xml, TextData) AS Deadlock_Graph, ServerName
@EitanBlumin
EitanBlumin / QueryStore_Health Extended Event Session.sql
Created Jul 9, 2018
QueryStore_Health Extended Event Session
View QueryStore_Health Extended Event Session.sql
-- Get some metadata about query_store extended events
/*
select *
from sys.dm_xe_object_columns
where object_name like '%query_store%'
and name not in ('UUID','VERSION','CHANNEL','KEYWORD')
*/
/*
query_store_persist_on_shutdown_failed
@EitanBlumin
EitanBlumin / Calculate Max Memory for SQL.sql
Created Jul 16, 2018
Calculate Max Memory for SQL Server Instance
View Calculate Max Memory for SQL.sql
-- Max Memory Calculation
-- Based on Tiger Toolbox script BP_Check (Copyright Pedro Lopes)
DECLARE @sqlmajorver int, @systemmem int, @systemfreemem int, @maxservermem int, @numa_nodes_afinned int, @numa int
DECLARE @mwthreads_count int, @mwthreads int, @arch smallint, @sqlcmd nvarchar(4000)
DECLARE @MinMBMemoryForOS INT, @RecommendedMaxMemMB INT
SET @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);
SET @arch = CASE WHEN @@VERSION LIKE '%<X64>%' THEN 64 WHEN @@VERSION LIKE '%<IA64>%' THEN 128 ELSE 32 END;
SELECT @maxservermem = CONVERT(int, [value]) FROM sys.configurations (NOLOCK) WHERE [Name] = 'max server memory (MB)';
View Data Driven Alternative Email and File Share.sql
-- Based on script by Jason Selburg
-- https://www.sqlservercentral.com/Forums/Topic279460-150-1.aspx
-- http://www.sqlservercentral.com/scripts/Miscellaneous/31733/
USE ReportServer
GO
IF OBJECT_ID(N'[dbo].[data_driven_subscription]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[data_driven_subscription]
GO
@EitanBlumin
EitanBlumin / Get Recent SQL Error Log Errors.sql
Created Nov 22, 2018
Coalesces error messages from SQL Error Log into one row per exception
View Get Recent SQL Error Log Errors.sql
DECLARE @MinutesBackToCheck INT = 10;
SET NOCOUNT ON;
DECLARE @start DATETIME;
SET @start=DATEADD(MINUTE,-@MinutesBackToCheck,GETDATE());
DECLARE @errors AS TABLE
(
ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
LogDate DATETIME,
View FilterParseJsonParameters.sql
/*
Fully Parameterized Search Query
--------------------------------
Copyright Eitan Blumin (c) 2018; email: eitan@madeiradata.com
You may use the contents of this SQL script or parts of it, modified or otherwise
for any purpose that you wish (including commercial).
Under the single condition that you include in the script
this comment block unchanged, and the URL to the original source, which is:
http://www.eitanblumin.com/
You can’t perform that action at this time.