Skip to content

Instantly share code, notes, and snippets.

View wsmelton's full-sized avatar
Little bit of this, little bit of that

Shawn Melton wsmelton

Little bit of this, little bit of that
View GitHub Profile
CREATE TABLE myTable (col1 varchar(2))
INSERT INTO myTable ('ts');
$os = Get-ItemProperty 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion' -ErrorVariable $osinfoError
$osInfoData = [pscustomobject]@{
"ProductName" = $os.ProductName;
"Version Number" = $os.CurrentVersion
#region Links
NOTE: Links are subject to change by Microsoft
Server Configuration Options BOL:
SQL Server 2014 -
SQL Server 2012 -
SQL Server 2008 R2 -
SQL Server 2008 -
SQL Server 2005 -
SQL Server 2000 -
wsmelton / Code_dbatools_settings.json
Created May 22, 2017 13:55
Color settings for VS Code and dbatools theme
//playing with color settings
"workbench.colorCustomizations": {
"activityBar.background": "#F0EBD7",
"activityBar.foreground": "#C9A735",
"activityBarBadge.foreground": "#3F3C3D",
"activityBarBadge.background": "#FFFFFF",
"panel.background": "#F3F7F2",
"statusBar.background": "#BFB297",
"statusBar.foreground": "#FFFFFF",
"sideBar.background": "#383636",
wsmelton / Out-CodeView.ps1
Created July 1, 2017 02:51
Generate Content View utilizing VS Code from an input object
Generate an HTML view that will open in an editor for VS Code
Add this to your Microsoft.VSCode_profile.ps1 file
$results = Get-DbaSpConfigure -SqlInstance manatarms
Out-CodeView $results
function Out-CodeView {
wsmelton / Get-MyEc2Instance
Created September 17, 2017 22:05
Pull the list of EC2 instances running under your AWS account, based on using a tag called "owner"
[string]$OwnerValue = 'melton',
$myEc2Instances = Get-EC2Tag -Filter @{ Name="key"; Values="owner" },@{ Name="value";Values=$OwnerValue}, @{ Name="resource-type";Values="instance"}
$data = Get-EC2Instance -InstanceId $myEc2Instances.ResourceId | Select-Object -ExpandProperty Instances
if ($Raw) {
foreach ($d in $data) {
$value = ($d.Tags | Where-Object Key -eq Name).Value
wsmelton / sql.json
Created April 26, 2018 22:48
SQL Ops Studio - User Snippets
"New SQL Login": {
"prefix": "new-sql-login",
"body": [
"CREATE LOGIN [${1:name of the login}] WITH PASSWORD = N'${2:password value}', CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF;",
"description": "Create a new SQL Login"
"New Windows Login": {
"prefix": "new-windows-login",
wsmelton / backup-history.sql
Created May 10, 2018 13:37
Get backup history details
SELECT distinct AS 'DatabaseName'
,(datediff( ss, t3.backup_start_date, t3.backup_finish_date)) AS 'DurationInSeconds'
,t3.user_name AS 'UserResponsible'
, AS backup_name
wsmelton / keybinds.json
Created July 30, 2018 14:10
My key bindings for VS Code
// Place your key bindings in this file to overwrite the defaults
"key": "alt+up",
"command": "workbench.action.navigateUp"
"key": "alt+down",
"command": "workbench.action.navigateDown"
wsmelton / PBM-Test-Policy-Condition.sql
Created September 6, 2018 01:36
Sample policy and conditions
/* All Conditions */
DECLARE @condition_id INT
EXEC msdb.dbo.sp_syspolicy_add_condition
@description=N'Verify AutoShrink is disabled',