Skip to content

Instantly share code, notes, and snippets.

View AshFlaw's full-sized avatar

AshFlaw

  • The Full Circle
View GitHub Profile
@AshFlaw
AshFlaw / Set-SQLCleanupDBO_Users_QS.ps1
Created September 20, 2017 12:11
Quick cleanup of a SQL 2016 instance for DB Owners, Orphaned users and enabling Query Store
$Instance = ""
Set-DbaDatabaseOwner -SqlServer $Instance
Remove-SqlOrphanUser -SqlServer $Instance
Set-DbaQueryStoreConfig -SqlServer $Instance `
-State ReadWrite `
-FlushInterval 600 `
-CollectionInterval 10 `
-MaxSize 100 `
-CaptureMode All `
-CleanupMode Auto `
@AshFlaw
AshFlaw / Uninstall-OMSAgent.ps1
Created September 20, 2017 12:09
Uninstall the OMS Microsoft Monitoring Agent.
$server = ""
$app = Get-WmiObject -Class Win32_Product -computer $server | Where-Object {$_.Name -match "Microsoft Monitoring Agent"}
$app.Uninstall()
@AshFlaw
AshFlaw / Set-SQLDBMultiUser.sql
Created September 20, 2017 12:06
Set a given DB back to multi user mode when locked by a given SPID
kill <SPID>
USE [master]
ALTER DATABASE <DBName>
SET MULTI_USER
GO