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"
View ParseXMLFilterParameters_Example.sql
/*
Fully Parameterized Search Query
--------------------------------
Copyright Eitan Blumin (c) 2014; 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.madeiradata.com/author/eitan/
View check_untrusted_foreign_keys.sql
IF OBJECT_ID('tempdb..#tmp') IS NOT NULL DROP TABLE #tmp;
CREATE TABLE #tmp (DBName SYSNAME, SchemaName SYSNAME, TableName SYSNAME, FullTableName AS QUOTENAME(SchemaName) + N'.' + QUOTENAME(TableName), UntrustedObject SYSNAME);
INSERT INTO #tmp(DBName, SchemaName, TableName, UntrustedObject)
EXEC sp_MSforeachdb 'IF EXISTS (SELECT * FROM sys.databases WHERE state_desc = ''ONLINE'' AND name = ''?'' AND DATABASEPROPERTYEX(''?'', ''Updateability'') = ''READ_WRITE'')
BEGIN
USE [?];
SELECT ''?'', OBJECT_SCHEMA_NAME(parent_object_id), OBJECT_NAME(parent_object_id), [name]
FROM [?].sys.foreign_keys
WHERE is_not_trusted = 1 AND is_not_for_replication = 0 AND is_disabled = 0;
@EitanBlumin
EitanBlumin / SentryOne_AlwaysOn_Inventory_Check.sql
Created Aug 20, 2020
Query to run in the SentryOne database to check your inventory of AlwaysOn Availability Groups
View SentryOne_AlwaysOn_Inventory_Check.sql
SELECT SiteName, ReplicaName
, NumberOfAvailabilityGroups = COUNT(DISTINCT AGName)
, NumberOfPrimaries = COUNT(DISTINCT PrimaryReplica)
FROM
(
SELECT DISTINCT
ES.ObjectName AS ReplicaName, S.Name AS SiteName
, AG.Name AS AGName
, AG.PrimaryReplica
FROM [SentryOne].[AlwaysOn].[AvailabilityGroup] AS AG
@EitanBlumin
EitanBlumin / PrintMax_Minified_Temporary_Procedure.sql
Last active Sep 2, 2020
This is a minified version of the PrintMax procedure (originally written by Ben Dill). It's created as a temporary procedure.
View PrintMax_Minified_Temporary_Procedure.sql
IF OBJECT_ID('tempdb..#PrintMax') IS NOT NULL DROP PROC #PrintMax;
GO
/*
Author: Eitan Blumin (t: @EitanBlumin | b: eitanblumin.com)
Description:
This is a minified version of the PrintMax procedure (originally written by Ben Dill).
It's created as a temporary procedure.
*/
CREATE PROCEDURE #PrintMax @str NVARCHAR(MAX)
AS
@EitanBlumin
EitanBlumin / Script.PreDeployment.CLR_Signing.sql
Created Jun 19, 2020
Pre-Deployment Script Template for Importing a Signed CLR Assembly (SSDT Project)
View Script.PreDeployment.CLR_Signing.sql
/*
Pre-Deployment Script Template for Importing a Signed CLR Assembly (SSDT Project)
--------------------------------------------------------------------------------------
In order to use this script, you must configure the following SQLCMD Variables in your project:
$(PathToSignedDLL)
$(CLRKeyName)
$(CLRLoginName)
To configure your SQLCMD Variables: Right-click on your DB project, select "Properties", and go to "SQLCMD Variables".
@EitanBlumin
EitanBlumin / Generate-FileRecoveryFromVault.ps1
Last active Sep 2, 2020
Generate a File Recovery script for a specified VM in an Azure Recovery Services Vault
View Generate-FileRecoveryFromVault.ps1
# Copyright 2020 Eitan Blumin <@EitanBlumin, https://www.eitanblumin.com>
# while at Madeira Data Solutions <https://www.madeiradata.com>
#
# Licensed under the MIT License (the "License");
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR CO