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
set nocount on; | |
drop table if exists #objects; | |
drop table if exists #ddps; | |
select object_id, identity(int,1,1) as id | |
into #objects | |
from sys.objects as o | |
where o.type = 'U' /* USER_TABLE */ | |
and o.is_ms_shipped = 0; |
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 System; | |
public static class TelemetryClientExtensions | |
{ | |
public static TResult TrackDependencyTiming<TResult>(this TelemetryClient client, string dependencyName, string commandName, Func<TResult> function) | |
{ | |
var startTime = DateTime.UtcNow; | |
var timer = System.Diagnostics.Stopwatch.StartNew(); | |
var success = true; |
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
{ | |
"incidentname": "Test", | |
"IncludeSearchResults": true, | |
"SearchResults": { | |
"id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/oi-default-east-us/providers/Microsoft.OperationalInsights/workspaces/...|2017-08-0607-46-30Z", | |
"__metadata": { | |
"top": 2147483647, | |
"RequestId": "4a37b79a-a875-40ad-9cbc-9d3dfcfa4df7|2017-08-0607-46-30Z", | |
"Status": "Successful", | |
"NumberOfDocuments": 0, |
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 ReportServer | |
go | |
drop table if exists #failedSubs | |
select c.ItemID | |
,u.UserName as SubscriptionOwner | |
,s.Description as SubscriptionDescription | |
,s.LastStatus | |
,s.SubscriptionID | |
,c.Name as ReportName |
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
############ | |
# Remove a tag | |
$tagToRemove = "SupportContact" | |
Write-Host [Start] Tag utilisation: $tagToRemove | |
Get-AzureRmTag -Name $tagToRemove | |
## Remove from resources | |
$resources = Find-AzureRmResource -Tag @{$tagToRemove=$null} | |
foreach($resource in $resources) | |
{ |
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
if not exists (select 1 from sys.schemas as s where s.name = 'logs') | |
exec('create schema logs authorization dbo'); | |
go | |
if not exists(select 1 from sys.schemas as s where s.name = 'logging') | |
exec('create schema logging authorization dbo'); | |
go | |
create table logs.InstanceWaitStats | |
( | |
CollectionTime datetime2(0) not null | |
,WaitType nvarchar(60) not null |
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
Import-Module C:\src\tsqlScheduler\src\Modules\tsqlScheduler -Verbose -Force | |
$pathToTaskToDelete = "C:\src\DBTasks\AGName\AGName-DBName-JobToDelete.json" | |
$ag = "AGName" | |
$db = "SchedulerDBName" | |
$domain = "foo.corp" | |
$serverInstance = "$ag.$domain" | |
$task = (Get-Content -Raw $pathToTaskToDelete | ConvertFrom-Json) |
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
$leaver = "foo\tim.isleaving" | |
$newOwner = "foo\tim.isreplaced" | |
$rs2010 = New-WebServiceProxy -Uri "http://gogoreports/ReportServer/ReportService2010.asmx" -Namespace SSRS.ReportingService2010 -UseDefaultCredential ; | |
$allSubscriptions = $rs2010.ListSubscriptions("/") | |
$subsToMove = ($allSubscriptions | Where-Object { $_.Owner -like $leaver }) | |
$subsToMove | Select-Object Path, Owner, Report | Format-Table | |
$subsToMove | ForEach-Object { $rs2010.ChangeSubscriptionOwner($_.SubscriptionID, $newOwner) } |
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
# has a -whatif | |
$cred = get-credential | |
$servers = @("server1", "server2") | |
foreach($server in $servers) | |
{ | |
Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock { get-msmqqueue | where-object { $_.QueueName -like "*somequeuewildcard*" } | Clear-MsmqQueue -WhatIf } | |
} |
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.* |
OlderNewer