This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.ApplicationInsights; | |
using Microsoft.ApplicationInsights.DependencyCollector; | |
using Microsoft.ApplicationInsights.Extensibility; | |
using System; | |
using System.Collections.Generic; | |
using System.Data.SqlClient; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-data-collector-api | |
Function Get-LogAnalyticsSignature { | |
[cmdletbinding()] | |
Param ( | |
$customerId, | |
$sharedKey, | |
$date, | |
$contentLength, | |
$method, | |
$contentType, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Hadoop.Avro.Container; | |
using Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Text; | |
namespace AvroReader | |
{ | |
public class AvroEventData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -RunAsAdministrator | |
$serviceName = "BITS" | |
$cutoffGB = 0.0001 | |
$processId = (Get-WMIObject win32_service | where { $_.name -eq $serviceName}).ProcessID | |
$process = Get-Process -Id $processId | |
$workingSet = $process.WorkingSet64 | |
$workingSetGB = $workingSet / 1GB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$text = Get-Content .\src\SQLChecks\Tests\Databases.tests.ps1 | |
$ast = [Management.Automation.Language.Parser]::ParseInput($text, [ref]$null, [ref]$null) | |
$ast.FindAll({ | |
param($t) | |
$t -is [System.Management.Automation.Language.CommandAst] -and | |
$t.CommandElements[0].Value -eq "Describe" | |
}, $true) | ForEach-Object { | |
$_.CommandElements[3].Value | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @mailFromDomain nvarchar(128) = N'@foo.com' | |
declare @username nvarchar(128) = 'apikey' | |
declare @password nvarchar(128) = 'SG.SECRETS'; | |
declare @port int = 587; | |
declare @server nvarchar(128) = 'smtp.sendgrid.com' | |
declare @replyTo nvarchar(128) = 'donotreply' + @mailFromDomain; | |
declare @serverName nvarchar(128) = substring(@@servername,8,100); | |
declare @emailAddress nvarchar(128) = @serverName + @mailFromDomain; | |
declare @displayName nvarchar(128) = @serverName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @defaultProfileId int; | |
select @defaultProfileId = pp.profile_id | |
from dbo.sysmail_principalprofile as pp | |
where pp.principal_sid = 0x00 /* Guest */ | |
and pp.is_default = 1 | |
if @defaultProfileId is null | |
begin | |
;throw 50000, 'No default profile set', 1 | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cred = Get-Credential -UserName "foo\admin" | |
$servers = @("server1","server2") | |
foreach($server in $servers) | |
{ | |
Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock { | |
Add-LocalGroupMember -Group "Performance Monitor Users" -Member "foo\service1" | |
Add-LocalGroupMember -Group "Performance Monitor Users" -Member "foo\service2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use msdb | |
go | |
declare @id int = 0 | |
select j.job_id, identity(int,1,1) as id | |
into #jobs | |
from dbo.sysjobs as j | |
join dbo.syscategories as c | |
on c.category_id = j.category_id | |
where c.name = 'Report Server' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select datediff(minute, dtdt.database_transaction_begin_time, getutcdate()) as TransactionDurationMinutes | |
,d.name as DatabaseName | |
,dtst.session_id | |
,dtdt.database_transaction_log_record_count | |
,cast(dtdt.database_transaction_log_bytes_used / 1024. / 1024. as decimal(17,2)) as LogUsedMB | |
,des.program_name | |
,des.host_name | |
,des.nt_user_name | |
,map.* | |
,dest.* |