Skip to content

Commit

Permalink
Merge pull request #4 from sqlcollaborative/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
dbaduck authored Feb 10, 2019
2 parents b96f66c + a604747 commit 54034ba
Show file tree
Hide file tree
Showing 1,441 changed files with 223,327 additions and 90,764 deletions.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_Report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ about: Found errors or unexpected behavior using dbatools module
- [ ] Verified this bug is not already reported in an issue
- [ ] Verified errors are not related to permissions
- [ ] Can reproduce in a clean PowerShell session (_clean = `powershell -NoProfile`_)
- [ ] If issue is with `Copy-DbaDatabase`, using `Backup-DbaDatabase | Restore-DbaDatabase` still does not work

Note that we do not have the resources to make `Copy-DbaDatabase` work in every environment. Instead, we try to ensure Backup & Restore work in your enviornment.

## Steps to Reproduce

Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [ ] Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
- [ ] Adding code coverage to existing functionality
- [ ] Pester test is included
- [ ] If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
- [ ] Nunit test is included
- [ ] Documentation
- [ ] Build system
Expand Down
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"MD024": false,
"MD022": false,
"MD032": false,
"MD013": false,
"MD001": true
}
257 changes: 257 additions & 0 deletions .vscode/dbatools.code-snippets
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"
}
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
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"
]
}
19 changes: 19 additions & 0 deletions .vscode/settings.json
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"
}
Loading

0 comments on commit 54034ba

Please sign in to comment.