From 162701efeaf246b190f66bf545c50bff0d79053c Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Tue, 12 Mar 2019 13:24:27 -0400 Subject: [PATCH 1/9] Added SQL PowerShell Examples Added examples specific to the official SqlServer PowerShell module, to help customers get started. --- .../README_FOR_MARKETPLACE.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index 87caf6e90e..0ae7478b50 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -101,3 +101,56 @@ For more information see the [Code of Conduct FAQ][conduct-FAQ] or contact [open [conduct-FAQ]: http://opensource.microsoft.com/codeofconduct/faq/ [conduct-email]: mailto:opencode@microsoft.com [conduct-md]: https://github.com/PowerShell/vscode-powershell/blob/master/CODE_OF_CONDUCT.md + +## SQL PowerShell Examples +In order to use these examples (below), you need to install the SqlServer module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/SqlServer). + +
Install-Module -Name SqlServer -AllowPrerelease
+ +In this example, we use the Get-SqlInstance cmdlet to Get the Server SMO objects for ServerA & ServerB. The default output for this command will include the Instance name, version, Service Pack, & CU Update Level of the instances. + +
Get-SqlInstance -ServerInstance ServerA, ServerB
+Here is a sample of what that output will look like: +
<# Sample Output #>
+Instance Name             Version    ProductLevel UpdateLevel
+-------------             -------    ------------ -----------
+ServerA                   13.0.5233  SP2          CU4
+ServerB                   14.0.3045  RTM          CU12
+ +In this example, we will do a 'dir' (alias for Get-ChildItem) to get the list of all SQL Server instances listed in your Registered Servers file, and then use the Get-SqlDatabase cmdlet to get a list of Databases for each of those instances. + +
dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse |
+WHERE {$_.Mode -ne 'd' } |
+FOREACH {
+        Get-SqlDatabase -ServerInstance $_.Name
+        }
+
+Here is a sample of what that output will look like: +

+Name                 Status           Size     Space  Recovery Compat. Owner
+                                            Available  Model     Level      
+----                 ------           ---- ---------- -------- ------- -----
+AdventureWorks2017   Normal      336.00 MB   57.01 MB Simple       140 sa   
+master               Normal        6.00 MB  368.00 KB Simple       140 sa   
+model                Normal       16.00 MB    5.53 MB Full         140 sa   
+msdb                 Normal       48.44 MB    1.70 MB Simple       140 sa   
+PBIRS                Normal      144.00 MB   55.95 MB Full         140 sa   
+PBIRSTempDB          Normal       16.00 MB    4.20 MB Simple       140 sa   
+SSISDB               Normal      325.06 MB   26.21 MB Full         140 sa   
+tempdb               Normal       72.00 MB   61.25 MB Simple       140 sa   
+WideWorldImporters   Normal         3.2 GB     2.6 GB Simple       130 sa   
+
+ +This example uses the Get-SqlDatabase cmdlet to retireve a list of all databases on the ServerB instance, then presents a grid/table to select which databases should be backed up. Once the user clicks on the "OK" button, only the highlighted databases will be backed up. + +
Get-SqlDatabase -ServerInstance ServerB |
+Out-GridView -PassThru |
+Backup-SqlDatabase -CompressionOption On
+ +This example again gets list of all SQL Server instances listed in your Registered Servers file, then reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. + +
dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse |
+WHERE {$_.Mode -ne 'd' } |
+FOREACH {
+        Get-SqlAgentJobHistory -ServerInstance  $_.Name -Since Midnight -OutcomesType Failed
+        }
From a66c7c77946be0e010bc55ff7a78d698b0ea8917 Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Tue, 12 Mar 2019 15:49:11 -0400 Subject: [PATCH 2/9] Update Code Formatting Updated the format of the code examples. --- .../README_FOR_MARKETPLACE.md | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index 0ae7478b50..c3c1c5fd94 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -105,28 +105,36 @@ For more information see the [Code of Conduct FAQ][conduct-FAQ] or contact [open ## SQL PowerShell Examples In order to use these examples (below), you need to install the SqlServer module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/SqlServer). -
Install-Module -Name SqlServer -AllowPrerelease
+``` +Install-Module -Name SqlServer -AllowPrerelease +``` + +In this example, we use the `Get-SqlInstance` cmdlet to Get the Server SMO objects for ServerA & ServerB. The default output for this command will include the Instance name, version, Service Pack, & CU Update Level of the instances. -In this example, we use the Get-SqlInstance cmdlet to Get the Server SMO objects for ServerA & ServerB. The default output for this command will include the Instance name, version, Service Pack, & CU Update Level of the instances. +``` +Get-SqlInstance -ServerInstance ServerA, ServerB +``` -
Get-SqlInstance -ServerInstance ServerA, ServerB
Here is a sample of what that output will look like: -
<# Sample Output #>
+
+```
 Instance Name             Version    ProductLevel UpdateLevel
 -------------             -------    ------------ -----------
 ServerA                   13.0.5233  SP2          CU4
-ServerB                   14.0.3045  RTM          CU12
+ServerB 14.0.3045 RTM CU12 +``` -In this example, we will do a 'dir' (alias for Get-ChildItem) to get the list of all SQL Server instances listed in your Registered Servers file, and then use the Get-SqlDatabase cmdlet to get a list of Databases for each of those instances. +In this example, we will do a `dir` (alias for `Get-ChildItem`) to get the list of all SQL Server instances listed in your Registered Servers file, and then use the `Get-SqlDatabase` cmdlet to get a list of Databases for each of those instances. -
dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse |
+```
+dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse |
 WHERE {$_.Mode -ne 'd' } |
 FOREACH {
         Get-SqlDatabase -ServerInstance $_.Name
         }
-
+``` Here is a sample of what that output will look like: -

+```
 Name                 Status           Size     Space  Recovery Compat. Owner
                                             Available  Model     Level      
 ----                 ------           ---- ---------- -------- ------- -----
@@ -139,18 +147,22 @@ PBIRSTempDB          Normal       16.00 MB    4.20 MB Simple       140 sa
 SSISDB               Normal      325.06 MB   26.21 MB Full         140 sa   
 tempdb               Normal       72.00 MB   61.25 MB Simple       140 sa   
 WideWorldImporters   Normal         3.2 GB     2.6 GB Simple       130 sa   
-
+``` -This example uses the Get-SqlDatabase cmdlet to retireve a list of all databases on the ServerB instance, then presents a grid/table to select which databases should be backed up. Once the user clicks on the "OK" button, only the highlighted databases will be backed up. +This example uses the `Get-SqlDatabase` cmdlet to retireve a list of all databases on the ServerB instance, then presents a grid/table to select which databases should be backed up. Once the user clicks on the "OK" button, only the highlighted databases will be backed up. -
Get-SqlDatabase -ServerInstance ServerB |
+```
+Get-SqlDatabase -ServerInstance ServerB |
 Out-GridView -PassThru |
-Backup-SqlDatabase -CompressionOption On
+Backup-SqlDatabase -CompressionOption On +``` -This example again gets list of all SQL Server instances listed in your Registered Servers file, then reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. +This example again gets list of all SQL Server instances listed in your Registered Servers file, then calls the `Get-SqlAgentJobHistory` which reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. -
dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse |
+```
+dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse |
 WHERE {$_.Mode -ne 'd' } |
 FOREACH {
         Get-SqlAgentJobHistory -ServerInstance  $_.Name -Since Midnight -OutcomesType Failed
-        }
+ } +``` From 8602abe7d9f09725880e4a94405462f06f4090bd Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Tue, 12 Mar 2019 15:51:56 -0400 Subject: [PATCH 3/9] Moved SQL PowerShell Examples Moved location of SQL PowerShell Examples to be after Example Scripts. --- .../README_FOR_MARKETPLACE.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index c3c1c5fd94..f195f4010b 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -75,33 +75,6 @@ To open/view the extension's examples in Visual Studio Code, run the following f code (Get-ChildItem $Home\.azuredatastudio\extensions\ms-vscode.PowerShell-*\examples)[-1] ``` -## Contributing to the Code - -Check out the [development documentation](docs/development.md) for more details -on how to contribute to this extension! - -## Maintainers - -- [Keith Hill](https://github.com/rkeithhill) - [@r_keith_hill](http://twitter.com/r_keith_hill) -- [Tyler Leonhardt](https://github.com/tylerl0706) - [@TylerLeonhardt](http://twitter.com/tylerleonhardt) -- [Rob Holt](https://github.com/rjmholt) - -## License - -This extension is [licensed under the MIT License](LICENSE.txt). Please see the -[third-party notices](Third%20Party%20Notices.txt) file for details on the third-party -binaries that we include with releases of this project. - -## [Code of Conduct][conduct-md] - -This project has adopted the [Microsoft Open Source Code of Conduct][conduct-code]. -For more information see the [Code of Conduct FAQ][conduct-FAQ] or contact [opencode@microsoft.com][conduct-email] with any additional questions or comments. - -[conduct-code]: http://opensource.microsoft.com/codeofconduct/ -[conduct-FAQ]: http://opensource.microsoft.com/codeofconduct/faq/ -[conduct-email]: mailto:opencode@microsoft.com -[conduct-md]: https://github.com/PowerShell/vscode-powershell/blob/master/CODE_OF_CONDUCT.md - ## SQL PowerShell Examples In order to use these examples (below), you need to install the SqlServer module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/SqlServer). @@ -166,3 +139,30 @@ FOREACH { Get-SqlAgentJobHistory -ServerInstance $_.Name -Since Midnight -OutcomesType Failed } ``` + +## Contributing to the Code + +Check out the [development documentation](docs/development.md) for more details +on how to contribute to this extension! + +## Maintainers + +- [Keith Hill](https://github.com/rkeithhill) - [@r_keith_hill](http://twitter.com/r_keith_hill) +- [Tyler Leonhardt](https://github.com/tylerl0706) - [@TylerLeonhardt](http://twitter.com/tylerleonhardt) +- [Rob Holt](https://github.com/rjmholt) + +## License + +This extension is [licensed under the MIT License](LICENSE.txt). Please see the +[third-party notices](Third%20Party%20Notices.txt) file for details on the third-party +binaries that we include with releases of this project. + +## [Code of Conduct][conduct-md] + +This project has adopted the [Microsoft Open Source Code of Conduct][conduct-code]. +For more information see the [Code of Conduct FAQ][conduct-FAQ] or contact [opencode@microsoft.com][conduct-email] with any additional questions or comments. + +[conduct-code]: http://opensource.microsoft.com/codeofconduct/ +[conduct-FAQ]: http://opensource.microsoft.com/codeofconduct/faq/ +[conduct-email]: mailto:opencode@microsoft.com +[conduct-md]: https://github.com/PowerShell/vscode-powershell/blob/master/CODE_OF_CONDUCT.md From 159515de7e2d1c5a8bc44c24a1009696ba020d81 Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Tue, 12 Mar 2019 15:54:58 -0400 Subject: [PATCH 4/9] Typo Fixed typo in description. --- docs/azure_data_studio/README_FOR_MARKETPLACE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index f195f4010b..97c2bd1806 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -122,7 +122,7 @@ tempdb Normal 72.00 MB 61.25 MB Simple 140 sa WideWorldImporters Normal 3.2 GB 2.6 GB Simple 130 sa ``` -This example uses the `Get-SqlDatabase` cmdlet to retireve a list of all databases on the ServerB instance, then presents a grid/table to select which databases should be backed up. Once the user clicks on the "OK" button, only the highlighted databases will be backed up. +This example uses the `Get-SqlDatabase` cmdlet to retrieve a list of all databases on the ServerB instance, then presents a grid/table (using the `Out-GridView` cmdlet) to select which databases should be backed up. Once the user clicks on the "OK" button, only the highlighted databases will be backed up. ``` Get-SqlDatabase -ServerInstance ServerB | From cd867b4faf6af3efe479de411f1324381120fb11 Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Tue, 12 Mar 2019 15:59:40 -0400 Subject: [PATCH 5/9] Commas Commas. --- docs/azure_data_studio/README_FOR_MARKETPLACE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index 97c2bd1806..aba97d5b06 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -130,7 +130,7 @@ Out-GridView -PassThru | Backup-SqlDatabase -CompressionOption On ``` -This example again gets list of all SQL Server instances listed in your Registered Servers file, then calls the `Get-SqlAgentJobHistory` which reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. +This example, again, gets list of all SQL Server instances listed in your Registered Servers file, then calls the `Get-SqlAgentJobHistory` which reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. ``` dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse | From 5cade58d2d265ba33f8b96129a20642902744750 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 13 Mar 2019 12:19:47 -0400 Subject: [PATCH 6/9] Update docs/azure_data_studio/README_FOR_MARKETPLACE.md Co-Authored-By: SQLvariant --- docs/azure_data_studio/README_FOR_MARKETPLACE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index aba97d5b06..4c6e0dc57d 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -75,7 +75,7 @@ To open/view the extension's examples in Visual Studio Code, run the following f code (Get-ChildItem $Home\.azuredatastudio\extensions\ms-vscode.PowerShell-*\examples)[-1] ``` -## SQL PowerShell Examples +### SQL PowerShell Examples In order to use these examples (below), you need to install the SqlServer module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/SqlServer). ``` From 0d8f68def62dbe9e6f9fdb9a4813cd7ed12150d2 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 13 Mar 2019 12:20:06 -0400 Subject: [PATCH 7/9] Update docs/azure_data_studio/README_FOR_MARKETPLACE.md Co-Authored-By: SQLvariant --- docs/azure_data_studio/README_FOR_MARKETPLACE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index 4c6e0dc57d..444617a42c 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -101,7 +101,7 @@ In this example, we will do a `dir` (alias for `Get-ChildItem`) to get the list ``` dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse | -WHERE {$_.Mode -ne 'd' } | +WHERE { $_.Mode -ne 'd' } | FOREACH { Get-SqlDatabase -ServerInstance $_.Name } From 6d082124bb56905f4fec9bbaaac51c8b8efba38e Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 13 Mar 2019 12:22:23 -0400 Subject: [PATCH 8/9] Update docs/azure_data_studio/README_FOR_MARKETPLACE.md Co-Authored-By: SQLvariant --- docs/azure_data_studio/README_FOR_MARKETPLACE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index 444617a42c..e90bc8ee2a 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -106,7 +106,9 @@ FOREACH { Get-SqlDatabase -ServerInstance $_.Name } ``` + Here is a sample of what that output will look like: + ``` Name Status Size Space Recovery Compat. Owner Available Model Level From af15e85a321c6ea802447da6936ddb5820315107 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 13 Mar 2019 13:15:38 -0400 Subject: [PATCH 9/9] Apply suggestions from code review Co-Authored-By: SQLvariant --- .../README_FOR_MARKETPLACE.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/azure_data_studio/README_FOR_MARKETPLACE.md b/docs/azure_data_studio/README_FOR_MARKETPLACE.md index e90bc8ee2a..fecb864d2c 100644 --- a/docs/azure_data_studio/README_FOR_MARKETPLACE.md +++ b/docs/azure_data_studio/README_FOR_MARKETPLACE.md @@ -78,13 +78,13 @@ code (Get-ChildItem $Home\.azuredatastudio\extensions\ms-vscode.PowerShell-*\exa ### SQL PowerShell Examples In order to use these examples (below), you need to install the SqlServer module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/SqlServer). -``` +```powershell Install-Module -Name SqlServer -AllowPrerelease ``` In this example, we use the `Get-SqlInstance` cmdlet to Get the Server SMO objects for ServerA & ServerB. The default output for this command will include the Instance name, version, Service Pack, & CU Update Level of the instances. -``` +```powershell Get-SqlInstance -ServerInstance ServerA, ServerB ``` @@ -99,12 +99,12 @@ ServerB 14.0.3045 RTM CU12 In this example, we will do a `dir` (alias for `Get-ChildItem`) to get the list of all SQL Server instances listed in your Registered Servers file, and then use the `Get-SqlDatabase` cmdlet to get a list of Databases for each of those instances. -``` +```powershell dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse | WHERE { $_.Mode -ne 'd' } | FOREACH { - Get-SqlDatabase -ServerInstance $_.Name - } + Get-SqlDatabase -ServerInstance $_.Name +} ``` Here is a sample of what that output will look like: @@ -126,7 +126,7 @@ WideWorldImporters Normal 3.2 GB 2.6 GB Simple 130 sa This example uses the `Get-SqlDatabase` cmdlet to retrieve a list of all databases on the ServerB instance, then presents a grid/table (using the `Out-GridView` cmdlet) to select which databases should be backed up. Once the user clicks on the "OK" button, only the highlighted databases will be backed up. -``` +```powershell Get-SqlDatabase -ServerInstance ServerB | Out-GridView -PassThru | Backup-SqlDatabase -CompressionOption On @@ -134,12 +134,12 @@ Backup-SqlDatabase -CompressionOption On This example, again, gets list of all SQL Server instances listed in your Registered Servers file, then calls the `Get-SqlAgentJobHistory` which reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. -``` +```powershell dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' -Recurse | WHERE {$_.Mode -ne 'd' } | FOREACH { - Get-SqlAgentJobHistory -ServerInstance $_.Name -Since Midnight -OutcomesType Failed - } + Get-SqlAgentJobHistory -ServerInstance $_.Name -Since Midnight -OutcomesType Failed +} ``` ## Contributing to the Code