mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Added two examples for multi-instance Checks.
This commit is contained in:
@@ -331,6 +331,57 @@
|
||||
"outputs": [],
|
||||
"execution_count": 38
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### 7. Scaling up your Checks\r\n",
|
||||
"Running checks across multiple machines and writng their results back to the same table in SQL Server. You can keep you list of SQL Servers to check anywhere you want, in a text file, in an Excel spreadsheet, in a table you maintain yourself, the options are endless.\r\n",
|
||||
"\r\n",
|
||||
"Two options are shown below show features availabile that can be managed from SSMS or Azure Data Studio, and can accessed via the `SQLSERVER:\\` Provider, which is part of the `SqlServer` module.\r\n",
|
||||
"\r\n",
|
||||
"1. Registered Servers is feature of SSMS and stores a list of SQL Server instances in a local XML file.\r\n",
|
||||
"2. Central Management Server relise on a SQL Server to maintain the list of SQL Server instances (instead of a _local XML file_) and is available in both SSMS & Azure Data Studio."
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "0ad9518f-e770-4819-b4d1-7f5608c793b3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# This approach leverages the Registered Servers feature of SSMS to obtain a list of SQL Servers, and run checks against them.\r\n",
|
||||
"Get-ChildItem 'SQLSERVER:\\SQLRegistration\\Database Engine Server Group' | \r\n",
|
||||
"Where-Object { $_.mode -ne 'd'} | \r\n",
|
||||
"foreach \r\n",
|
||||
" {\r\n",
|
||||
" Get-SqlInstance -ServerInstance $_.Name |\r\n",
|
||||
" Invoke-SqlAssessment -FlattenOutput |\r\n",
|
||||
" Write-SqlTableData -ServerInstance localhost -DatabaseName SQLAssessmentDemo -SchemaName Assessment -TableName Results -Force\r\n",
|
||||
" }"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "3a0c510d-07c7-464b-8b0a-2152df24e237"
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"<# This approach leverages the Central Management Server feature to obtain a list of SQL Servers #>\r\n",
|
||||
"Get-ChildItem 'SQLSERVER:\\SQLRegistration\\Central Management Server Group' -Recurse | \r\n",
|
||||
"foreach {\r\n",
|
||||
" Get-SqlInstance -ServerInstance $_.Name | \r\n",
|
||||
" Invoke-SqlAssessment -FlattenOutput |\r\n",
|
||||
" Write-SqlTableData -ServerInstance localhost -DatabaseName SQLAssessmentDemo -SchemaName Assessment -TableName Results -Force\r\n",
|
||||
" }"
|
||||
],
|
||||
"metadata": {
|
||||
"azdata_cell_guid": "c6ca3196-b661-46b4-9818-502c779742ab"
|
||||
},
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
@@ -612,4 +663,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user