|
1 | 1 | function Invoke-PDCRepairClone { |
2 | | -<# |
3 | | -.SYNOPSIS |
4 | | - Invoke-PDCRepairClone repairs the clones |
| 2 | + <# |
| 3 | + .SYNOPSIS |
| 4 | + Invoke-PDCRepairClone repairs the clones |
5 | 5 |
|
6 | | -.DESCRIPTION |
7 | | - Invoke-PDCRepairClone has the ability to repair the clones when they have gotten disconnected from the image. |
8 | | - In such a case the clone is no longer available for the database server and the database will either not show |
9 | | - any information or the database will have the status (Recovery Pending). |
| 6 | + .DESCRIPTION |
| 7 | + Invoke-PDCRepairClone has the ability to repair the clones when they have gotten disconnected from the image. |
| 8 | + In such a case the clone is no longer available for the database server and the database will either not show |
| 9 | + any information or the database will have the status (Recovery Pending). |
10 | 10 |
|
11 | | - By running this command all the clones will be retrieved from the database for a certain host. |
| 11 | + By running this command all the clones will be retrieved from the database for a certain host. |
12 | 12 |
|
13 | | -.PARAMETER HostName |
14 | | - Set on or more hostnames to retrieve the configurations for |
| 13 | + .PARAMETER HostName |
| 14 | + Set on or more hostnames to retrieve the configurations for |
15 | 15 |
|
16 | | -.PARAMETER SqlCredential |
17 | | - Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted. To use: |
| 16 | + .PARAMETER SqlCredential |
| 17 | + Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted. To use: |
18 | 18 |
|
19 | | - $scred = Get-Credential, then pass $scred object to the -SqlCredential parameter. |
| 19 | + $scred = Get-Credential, then pass $scred object to the -SqlCredential parameter. |
20 | 20 |
|
21 | | - Windows Authentication will be used if SqlCredential is not specified. SQL Server does not accept Windows credentials being passed as credentials. |
22 | | - To connect as a different Windows user, run PowerShell as that user. |
| 21 | + Windows Authentication will be used if SqlCredential is not specified. SQL Server does not accept Windows credentials being passed as credentials. |
| 22 | + To connect as a different Windows user, run PowerShell as that user. |
23 | 23 |
|
24 | | -.PARAMETER EnableException |
25 | | - By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. |
26 | | - This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. |
27 | | - Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch. |
| 24 | + .PARAMETER EnableException |
| 25 | + By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. |
| 26 | + This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. |
| 27 | + Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch. |
28 | 28 |
|
29 | | -.PARAMETER WhatIf |
30 | | - If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run. |
| 29 | + .PARAMETER WhatIf |
| 30 | + If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run. |
31 | 31 |
|
32 | | -.PARAMETER Confirm |
33 | | - If this switch is enabled, you will be prompted for confirmation before executing any operations that change state. |
| 32 | + .PARAMETER Confirm |
| 33 | + If this switch is enabled, you will be prompted for confirmation before executing any operations that change state. |
34 | 34 |
|
35 | | -.NOTES |
36 | | - Author: Sander Stad (@sqlstad, sqlstad.nl) |
| 35 | + .NOTES |
| 36 | + Author: Sander Stad (@sqlstad, sqlstad.nl) |
37 | 37 |
|
38 | | - Website: https://psdatabaseclone.io |
39 | | - Copyright: (C) Sander Stad, sander@sqlstad.nl |
40 | | - License: MIT https://opensource.org/licenses/MIT |
| 38 | + Website: https://psdatabaseclone.io |
| 39 | + Copyright: (C) Sander Stad, sander@sqlstad.nl |
| 40 | + License: MIT https://opensource.org/licenses/MIT |
41 | 41 |
|
42 | | -.LINK |
43 | | - https://psdatabaseclone.io/ |
| 42 | + .LINK |
| 43 | + https://psdatabaseclone.io/ |
44 | 44 |
|
45 | | -.EXAMPLE |
46 | | - Invoke-PDCRepairClone -Hostname Host1 |
| 45 | + .EXAMPLE |
| 46 | + Invoke-PDCRepairClone -Hostname Host1 |
47 | 47 |
|
48 | | - Repair the clones for Host1 |
| 48 | + Repair the clones for Host1 |
49 | 49 |
|
50 | | -#> |
| 50 | + #> |
51 | 51 | [CmdLetBinding()] |
52 | 52 |
|
53 | 53 | param( |
|
80 | 80 | foreach ($hst in $HostName) { |
81 | 81 |
|
82 | 82 | $query = " |
83 | | - SELECT i.ImageLocation, |
84 | | - c.CloneLocation, |
85 | | - c.SqlInstance, |
86 | | - c.DatabaseName, |
87 | | - c.IsEnabled |
88 | | - FROM dbo.Clone AS c |
89 | | - INNER JOIN dbo.Image AS i |
90 | | - ON i.ImageID = c.ImageID |
91 | | - INNER JOIN dbo.Host AS h |
92 | | - ON h.HostID = c.HostID |
93 | | - WHERE h.HostName = '$hst'; |
94 | | - " |
| 83 | + SELECT i.ImageLocation, |
| 84 | + c.CloneLocation, |
| 85 | + c.SqlInstance, |
| 86 | + c.DatabaseName, |
| 87 | + c.IsEnabled |
| 88 | + FROM dbo.Clone AS c |
| 89 | + INNER JOIN dbo.Image AS i |
| 90 | + ON i.ImageID = c.ImageID |
| 91 | + INNER JOIN dbo.Host AS h |
| 92 | + ON h.HostID = c.HostID |
| 93 | + WHERE h.HostName = '$hst'; |
| 94 | + " |
95 | 95 |
|
96 | 96 | Write-PSFMessage -Message "Query Host Clones`n$query" -Level Debug |
97 | 97 |
|
|
0 commit comments