forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from sqlcollaborative/master
Master
- Loading branch information
Showing
1,441 changed files
with
223,327 additions
and
90,764 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"MD024": false, | ||
"MD022": false, | ||
"MD032": false, | ||
"MD013": false, | ||
"MD001": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
{ | ||
// Starting point for project-level snippets for the dbatools contributions. | ||
// These are just a few and will be exapnded as time goes along. | ||
|
||
"Get function for SMO object": { | ||
"scope": "powershell", | ||
"prefix": "getsmo", | ||
"body": [ | ||
"function Get-Dba$0 {", | ||
"<#", | ||
"\t.SYNOPSIS", | ||
"\t\t${1:Short of what command does}", | ||
"", | ||
"\t.DESCRIPTION", | ||
"\t\t${2:Longer of what command does}", | ||
"", | ||
"\t.PARAMETER SqlInstance", | ||
"\t\tSQL Server name or SMO object representing the SQL Server to connect to. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", | ||
"", | ||
"\t.PARAMETER SqlCredential", | ||
"\t\tLogin to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", | ||
"", | ||
"\t.PARAMETER EnableException", | ||
"\t\tBy default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.", | ||
"\t\tThis avoids overwhelming you with a \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.", | ||
"\t\tUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", | ||
"", | ||
"\t.NOTES", | ||
"\t\tTags: ${3:Singular word for command index}", | ||
"\t\tAuthor: ${4:FirstName} ${5:LastName} (@${6:TwitterHandle}), ${7:blog address}", | ||
"", | ||
"\t\tWebsite: https://dbatools.io", | ||
"\t\tCopyright: (c) 2018 by dbatools, licensed under MIT", | ||
"\t\tLicense: MIT https://opensource.org/licenses/MIT", | ||
"", | ||
"\t.LINK", | ||
"\t\thttps://dbatools.io/Get-Dba$0", | ||
"", | ||
"\t.EXAMPLE", | ||
"\t\tPS C:\\> Get-Dba$0 -SqlInstance localhost", | ||
"", | ||
"\t\t${8:Add minimum example for each parameter}", | ||
"", | ||
"#>", | ||
"\t[CmdletBinding()]", | ||
"\tparam (", | ||
"\t\t[parameter(Position = 0, Mandatory, ValueFromPipeline)]", | ||
"\t\t[Alias(\"ServerInstance\", \"SqlServer\")]", | ||
"\t\t[DbaInstance[]]\\$SqlInstance,", | ||
"\t\t[Alias(\"Credential\")]", | ||
"\t\t[PSCredential]\\$SqlCredential,", | ||
"\t\t[object[]]\\$${9:YourParameter},", | ||
"\t\t[switch]\\$EnableException", | ||
"\t)", | ||
"\tprocess {", | ||
"\t\tforeach (\\$instance in \\$SqlInstance) {", | ||
"\t\t\tWrite-Message -Level Verbose -Message \"Attempting to connect to \\$instance\"", | ||
"\t\t\ttry {", | ||
"\t\t\t\t\\$server = Connect-SqlInstance -SqlInstance \\$instance -SqlCredential \\$SqlCredential", | ||
"\t\t\t}", | ||
"\t\t\tcatch {", | ||
"\t\t\t\tStop-Function -Message \"Failure\" -Category ConnectionError -ErrorRecord \\$_ -Target \\$instance -Continue", | ||
"\t\t\t}", | ||
"", | ||
"\t\t\t# Add in filter code", | ||
"", | ||
"\t\t\t# Add in processing SMO object", | ||
"", | ||
"\t\t\t<# Output must include 3 properties for each object:", | ||
"\t\t\t\t1. ComputerName (\\$server.ComputerName)", | ||
"\t\t\t\t2. InstanceName (\\$server.ServiceName)", | ||
"\t\t\t\t3. SqlInstance (\\$server.DomainInstanceName)", | ||
"", | ||
"\t\t\t\t\"Select_DefaultView -InputObject \\$object -Property <property list\" can be used to only output certain properties", | ||
"\t\t\t\t\"Select_DefaultView -InputObject \\$object -ExcludeProperty <property list\" can be used to output everything but the list of properties", | ||
"\t\t\t#>", | ||
"\t\t}", | ||
"\t}", | ||
"}" | ||
], | ||
"description": "template for building a function to get properties from SMO object" | ||
}, | ||
"Set function": { | ||
"scope": "powershell", | ||
"prefix": "setsmo", | ||
"body": [ | ||
"function Set-Dba$0 {", | ||
"<#", | ||
"\t.SYNOPSIS", | ||
"\t\t${1:Short of what command does}", | ||
"", | ||
"\t.DESCRIPTION", | ||
"\t\t${2:Longer of what command does}", | ||
"", | ||
"\t.PARAMETER SqlInstance", | ||
"\t\tSQL Server name or SMO object representing the SQL Server to connect to. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", | ||
"", | ||
"\t.PARAMETER SqlCredential", | ||
"\t\tLogin to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", | ||
"", | ||
"\t.PARAMETER EnableException", | ||
"\t\tBy default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.", | ||
"\t\tThis avoids overwhelming you with a \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.", | ||
"\t\tUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", | ||
"", | ||
"\t.NOTES", | ||
"\t\tTags: ${3:Singular word for command index}", | ||
"\t\tAuthor: ${4:FirstName} ${5:LastName} (@${6:TwitterHandle}), ${7:blog address}", | ||
"", | ||
"\t\tWebsite: https://dbatools.io", | ||
"\t\tCopyright: (c) 2018 by dbatools, licensed under MIT", | ||
"\t\tLicense: MIT https://opensource.org/licenses/MIT", | ||
"", | ||
"\t.LINK", | ||
"\t\thttps://dbatools.io/Set-Dba$0", | ||
"", | ||
"\t.EXAMPLE", | ||
"\t\tPS C:\\> Set-Dba$0 -SqlInstance localhost", | ||
"", | ||
"\t\t${8:Add minimum example for each parameter}", | ||
"", | ||
"#>", | ||
"\t[CmdletBinding(SupportsShouldProcess, ConfirmImpact = \"High\")]", | ||
"\tparam (", | ||
"\t\t[parameter(Position = 0, Mandatory, ValueFromPipeline)]", | ||
"\t\t[Alias(\"ServerInstance\", \"SqlServer\")]", | ||
"\t\t[DbaInstance[]]\\$SqlInstance,", | ||
"\t\t[Alias(\"Credential\")]", | ||
"\t\t[PSCredential]\\$SqlCredential,", | ||
"\t\t[object[]]\\$${9:YourParameters},", | ||
"\t\t[switch]\\$EnableException", | ||
"\t)", | ||
"\tprocess {", | ||
"\t\tforeach (\\$instance in \\$SqlInstance) {", | ||
"\t\t\tWrite-Message -Level Verbose -Message \"Attempting to connect to \\$instance\"", | ||
"\t\t\ttry {", | ||
"\t\t\t\t\\$server = Connect-SqlInstance -SqlInstance \\$instance -SqlCredential \\$SqlCredential", | ||
"\t\t\t}", | ||
"\t\t\tcatch {", | ||
"\t\t\t\tStop-Function -Message \"Failure\" -Category ConnectionError -ErrorRecord \\$_ -Target \\$instance -Continue", | ||
"\t\t\t}", | ||
"", | ||
"\t\t\t# Add code for parameter filters", | ||
"", | ||
"\t\t\tforeach (\\$object in \\$objects) {", | ||
"\t\t\t\tif (\\$Pscmdlet.ShouldProcess(\"\\$object on \\$server\", \"What it will do\")) {", | ||
"\t\t\t\t\t\t# Work to be done", | ||
"", | ||
"\t\t\t\t\t\t[PSCustomObject]@{", | ||
"\t\t\t\t\t\t\tComputerName = \\$server.NetName", | ||
"\t\t\t\t\t\t\tInstanceName = \\$server.ServiceName", | ||
"\t\t\t\t\t\t\tSqlInstance = \\$server.DomainInstanceName", | ||
"\t\t\t\t\t\t\tObject = \\$object.Name", | ||
"\t\t\t\t\t\t\tStatus = \"Dropped/Updated/etc\"", | ||
"\t\t\t\t\t\t}", | ||
"\t\t\t\t\t}", | ||
"\t\t\t}", | ||
"\t\t}", | ||
"\t}", | ||
"}" | ||
], | ||
"description": "template for building a function to set properties from SMO object" | ||
}, | ||
|
||
"Set function": { | ||
"scope": "powershell", | ||
"prefix": "setsql", | ||
"body": [ | ||
"function Set-Dba$0 {", | ||
"<#", | ||
"\t.SYNOPSIS", | ||
"\t\t${1:Short of what command does}", | ||
"", | ||
"\t.DESCRIPTION", | ||
"\t\t${2:Longer of what command does}", | ||
"", | ||
"\t.PARAMETER SqlInstance", | ||
"\t\tSQL Server name or SMO object representing the SQL Server to connect to. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", | ||
"", | ||
"\t.PARAMETER SqlCredential", | ||
"\t\tLogin to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", | ||
"", | ||
"\t.PARAMETER EnableException", | ||
"\t\tBy default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.", | ||
"\t\tThis avoids overwhelming you with a \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.", | ||
"\t\tUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", | ||
"", | ||
"\t.NOTES", | ||
"\t\tTags: ${3:Singular word for command index}", | ||
"\t\tAuthor: ${4:FirstName} ${5:LastName} (@${6:TwitterHandle}), ${7:blog address}", | ||
"", | ||
"\t\tWebsite: https://dbatools.io", | ||
"\t\tCopyright: (c) 2018 by dbatools, licensed under MIT", | ||
"\t\tLicense: MIT https://opensource.org/licenses/MIT", | ||
"", | ||
"\t.LINK", | ||
"\t\thttps://dbatools.io/Set-Dba$0", | ||
"", | ||
"\t.EXAMPLE", | ||
"\t\tPS C:\\> Set-Dba$0 -SqlInstance localhost", | ||
"", | ||
"\t\t${8:Add minimum example for each parameter}", | ||
"", | ||
"#>", | ||
"\t[CmdletBinding(SupportsShouldProcess, ConfirmImpact = \"High\")]", | ||
"\tparam (", | ||
"\t\t[parameter(Position = 0, Mandatory, ValueFromPipeline)]", | ||
"\t\t[Alias(\"ServerInstance\", \"SqlServer\")]", | ||
"\t\t[DbaInstance[]]\\$SqlInstance,", | ||
"\t\t[Alias(\"Credential\")]", | ||
"\t\t[PSCredential]\\$SqlCredential,", | ||
"\t\t[object[]]\\$${9:YourParameters},", | ||
"\t\t[switch]\\$EnableException", | ||
"\t)", | ||
"\tbegin {", | ||
"\t\t\\$sql = \"--FORMART YOUR T-SQL, poorsql.com", | ||
"\t\t\t\\-- build your query based on parameters passed in", | ||
"\t\t\"", | ||
"\t}", | ||
"\tprocess {", | ||
"\t\tforeach (\\$instance in \\$SqlInstance) {", | ||
"\t\t\tWrite-Message -Level Verbose -Message \"Attempting to connect to \\$instance\"", | ||
"\t\t\ttry {", | ||
"\t\t\t\t\\$server = Connect-SqlInstance -SqlInstance \\$instance -SqlCredential \\$SqlCredential", | ||
"\t\t\t}", | ||
"\t\t\tcatch {", | ||
"\t\t\t\tStop-Function -Message \"Failure\" -Category ConnectionError -ErrorRecord \\$_ -Target \\$instance -Continue", | ||
"\t\t\t}", | ||
"", | ||
"\t\t\t# Add code for parameter filters", | ||
"", | ||
"\t\t\tforeach (\\$object in \\$objects) {", | ||
"\t\t\t\ttry {", | ||
"\t\t\t\t\t\\$results = \\$server.Query(\\$sql)", | ||
"\t\t\t\t}", | ||
"\t\t\t\tcatch {", | ||
"\t\t\t\t\tStop-Function -Message \"Something went wrong\" -Continue -Target \\$object -ErrorRecord \\$_", | ||
"\t\t\t\t}", | ||
"\t\t\t\tforeach (\\$row in \\$results) {", | ||
"\t\t\t\t\t# Work to be done", | ||
"", | ||
"\t\t\t\t\t[PSCustomObject]@{", | ||
"\t\t\t\t\t\tComputerName = \\$server.NetName", | ||
"\t\t\t\t\t\tInstanceName = \\$server.ServiceName", | ||
"\t\t\t\t\t\tSqlInstance = \\$server.DomainInstanceName", | ||
"\t\t\t\t\t\tObject = \\$row.ColumnName", | ||
"\t\t\t\t\t\tStatus = \"Dropped/Updated/Whatever\"", | ||
"\t\t\t\t\t}", | ||
"\t\t\t\t}", | ||
"\t\t\t}", | ||
"\t\t}", | ||
"\t}", | ||
"}" | ||
], | ||
"description": "template for building a function to set properties from SMO object" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"ms-vscode.PowerShell", | ||
"dbatools.search" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
// cleans up whitespace | ||
"files.trimTrailingWhitespace": true, | ||
|
||
// formatting style this project adheres to: https://en.wikipedia.org/wiki/Indentation_style#Variant:_1TBS_(OTBS) | ||
"powershell.codeFormatting.preset": "OTBS", | ||
|
||
// editor settings for formatting standards on this project | ||
"editor.tabSize": 4, | ||
"editor.detectIndentation": false, | ||
"editor.insertSpaces": true, | ||
"editor.formatOnSave": true, | ||
|
||
// editor settings that will auto add the closing quote or curly brace | ||
"editor.autoClosingBrackets": "always", | ||
"editor.autoClosingQuotes": "always", | ||
"editor.autoSurround": "languageDefined" | ||
} |
Oops, something went wrong.