-
Notifications
You must be signed in to change notification settings - Fork 511
Added SQL PowerShell Examples #1787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added examples specific to the official SqlServer PowerShell module, to help customers get started.
## 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). | ||
|
||
<pre><code>Install-Module -Name SqlServer -AllowPrerelease</code></pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we are recommending a prerelease version of this module rather than the last stable version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, great catch. I pulled that in from my recent post. The latest Prerelease includes Invoke-Sqlcmd working on PSCore. Since Azure Data Studio is cross-platform, having the x-plat Invoke-Sqlcmd is very useful and relevant to those customers. We can either pull the " -AllowPrerelease" portion now, or we can wait until the final version of the module ships, and pull it then.
Although, ironically, if PSCore still hasn't shipped then the customer would have to download that preview as well. (We could include a link to the post on the PowerShell blog as well, to help the x-plat customers)
In my mind, there is literally no other SQL PowerShell cmdlet as important as Invoke-Sqlcmd. I can't ever see broadly suggesting customers use a -AllowPrerelease version after this one ships.
I'm fine with leaving " -AllowPrerelease" until the ned of the month, or pulling it now. Up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with -AllowPrerelease
but please add a comment as to why we're installing the prerelease one.
This looks great to me overall, thanks for the contribution! |
@SQLvariant can you switch your
and for the output ones, use:
|
ServerA 13.0.5233 SP2 CU4 | ||
ServerB 14.0.3045 RTM CU12</code></pre> | ||
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single backticks for inline markdown formatting.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. I can take care of that right now.
WideWorldImporters Normal 3.2 GB 2.6 GB Simple 130 sa | ||
</code></pre> | ||
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Out-GridView -PassThru | | ||
Backup-SqlDatabase -CompressionOption On</code></pre> | ||
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 reports every failed SQL Agent Job since Midnight, for each SQL Server instances listed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Can you move this newly added section after the |
Updated the format of the code examples.
Moved location of SQL PowerShell Examples to be after Example Scripts.
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just some minor nitpicks.
Co-Authored-By: SQLvariant <[email protected]>
Co-Authored-By: SQLvariant <[email protected]>
Co-Authored-By: SQLvariant <[email protected]>
Co-Authored-By: SQLvariant <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Added examples specific to the official SqlServer PowerShell module, to help customers get started.
PR Summary
Added examples specific to the official SqlServer PowerShell module, to the README_FOR_MARKETPLACE.md file.
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
x
between the square brackets.Please mark anything not applicable to this PR
NA
.WIP:
to the beginning of the title and remove the prefix when the PR is ready