Skip to content

Instantly share code, notes, and snippets.

View jzabroski's full-sized avatar
🎯
Focusing

John Zabroski jzabroski

🎯
Focusing
View GitHub Profile
@jzabroski
jzabroski / Execution-Cache-Single-Use-Plans-Explore.sql
Last active July 18, 2017 12:43 — forked from LitKnd/Execution-Cache-Single-Use-Plans-Explore.sql
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]
@jzabroski
jzabroski / TSQL Security Audit Report
Last active April 8, 2024 10:50
TSQL Security Audit Report.
/*
--Script source found at : http://stackoverflow.com/a/7059579/1387418
Security Audit Report
1) List all access provisioned to a sql user or windows user/group directly
2) List all access provisioned to a sql user or windows user/group through a database or application role
3) List all access provisioned to the public role
@jzabroski
jzabroski / Create_SQLAgentJobSripts.ps1
Created July 26, 2017 20:09
PS script to generate all SQL Server Agent jobs on the given instance.
# Date: 16/02/14
# Author: John Sansom
# Description: PS script to generate all SQL Server Agent jobs on the given instance.
# The script accepts an input file of server names.
# Version: 1.1
#
# Example Execution: .\Create_SQLAgentJobSripts.ps1 .\ServerNameList.txt
param([String]$ServerListPath)
@jzabroski
jzabroski / SSRS-ExportReports.ps1
Created July 28, 2017 21:52
Export of SSRS reports datasources and images
<# .SYNOPSIS
Export of SSRS reports datasources and images
.DESCRIPTION
This PowerShell script exports all (or filtered) reports, data sources and images directly from the ReportServer database
to a specified folder. For the file name the complete report path is used; for file name invalid characters are replaced with a -.
Reports are exported with .rdl as extension, data sources with .rds and resources without any additional extension.
Please change the "Configuration data" below to your enviroment.
Works with SQL Server 2005 and higher versions in all editions.
Requires SELECT permission on the ReportServer database.
.NOTES
-- Taken from: http://sqlblog.com/blogs/hugo_kornelis/archive/2014/07/18/database-mail-and-then-the-smtp-server-changed.aspx
DECLARE @NewServer sysname = 'NotTelling.mail', -- New SMTP server
@OldServer sysname = 'MySecret.mail', -- Old SMTP server
@account_id int;
DECLARE Cursor_MailAccounts CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY
FOR SELECT account_id
FROM msdb.dbo.sysmail_server
WHERE servername = @OldServer; -- Add extra logic here
@jzabroski
jzabroski / New-RsSubscription_0.0.2.9_hotfix
Created October 20, 2017 22:08
Hotfix for ReportingServicesTools Issue #85
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
function New-RsSubscription {
<#
.SYNOPSIS
This script creates a new reporting subscription.
.DESCRIPTION
This script creates a new reporting subscription based on the parameters provided. NOTE: A new subscriptionId will be generated.
@jzabroski
jzabroski / RestartService.ps1
Created December 4, 2017 17:58
Restart Windows Service and its currently running Dependent Services
Param (
[Parameter(Mandatory=$true)] [String]$ServiceName
)
<#
From: https://gallery.technet.microsoft.com/PowerShell-Script-for-8243e5d1
This is a PowerShell Script to restart a windows service with its dependent services. The dependent services that were not running when the restart request made, will not be started, so that the system services state will remain same after restart service script run.
#>
[System.Collections.ArrayList]$ServicesToRestart = @()
@jzabroski
jzabroski / Fix broken dependencies on all objects
Created March 15, 2018 14:20
Fix broken dependencies on all objects
-- Originally from: https://mssqlwiki.com/2012/05/04/copy-database-wizard-or-replication-setup-might-fail-due-to-broken-dependency/
--Below script will fix the broken dependencies on all the objects
----------------------------------------------------------------------------
--List of objects for which referenced objects are missing.
--ex: View created on table XYZ and table XYZ is dropped
----------------------------------------------------------------------------
SELECT OBJECT_NAME (referencing_id),referenced_database_name, referenced_schema_name, referenced_entity_name
FROM sys.sql_expression_dependencies
WHERE referenced_entity_name not in (select name from sysobjects)
@jzabroski
jzabroski / keybase.md
Created December 11, 2019 22:24
Keybase proof

Keybase proof

I hereby claim:

  • I am jzabroski on github.
  • I am johnzabroski (https://keybase.io/johnzabroski) on keybase.
  • I have a public key ASDMWKXdhimJDGdWnb6YFpabkXxft4PBiHEAWI1zDB-GMQo

To claim this, I am signing this object:

@jzabroski
jzabroski / CodeEval.cs
Created February 27, 2020 01:44 — forked from galenguyer/CodeEval.cs
Arbitrary Code Execution for C#
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Threading.Tasks;
/*
To execute, run
string code = "your code here";
if (!code.Contains("return")) code = "return " + code;
code = code.Trim().TrimEnd(';') + ";";