Skip to content

Commit 27e226a

Browse files
committed
Improved SQL Server support
1 parent f631830 commit 27e226a

9 files changed

+48
-28
lines changed

AsBuiltReport.Microsoft.Windows.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"ShowTableCaptions": true
1010
},
1111
"Options": {
12-
"Instance": "MSSQLSERVER"
12+
"SQLLogin": false,
13+
"SQLUserName": "",
14+
"SQLSecurePassword": ""
1315
},
1416
"InfoLevel": {
1517
"_comment_": "Please refer to the AsBuiltReport project contributing guide for information about how to define InfoLevels.",
@@ -57,7 +59,7 @@
5759
"BP": true
5860
},
5961
"SQLServer": {
60-
"Firewall": true
62+
"BP": true
6163
}
6264
}
6365
}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.5.3] - 2024-02-??
8+
## [0.5.3] - 2024-03-06
99

1010
### Added
1111

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,22 @@ The **Report** schema provides configuration of the Microsoft Windows report inf
185185

186186
The **Options** schema allows certain options within the report to be toggled on or off.
187187

188-
| Sub-Schema | Setting | Default | Description |
189-
| ---------- | ------------------- | ----------- | ------------------------------------------ |
190-
| Instance | SQL Server Instance | MSSQLSERVER | Set the sql server instance to connect to. |
188+
| Sub-Schema | Setting | Default | Description |
189+
| ----------------- | ------------ | ------- | ---------------------------------------- |
190+
| SQLLogin | true / false | false | Enable sql server login authentication . |
191+
| SQLUserName | User defined | empty | Sql server login Username . |
192+
| SQLSecurePassword | User defined | empty | Sql server login SecureString Password . |
193+
194+
#### Generating a SecureString
195+
196+
```powershell
197+
PS C:\> "SecurePassword" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString
198+
01000000d08c9ddf0115d1118c7a00c04fc297eb01000000b3605317d738c346801fbff6596b0d130000
199+
PS C:\>
200+
```
201+
Copy/Paste the output text to the variable SQLSecurePassword
202+
203+
##### Note: Storing any credential in a file can pose a security risk. Use this option at your own risk!
191204

192205
### InfoLevel
193206

Src/Private/Get-AbrWinSQLBackupDevice.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Get-AbrWinSQLBackupDevice {
4545
}
4646

4747
if ($InfoLevel.SQLServer -ge 2) {
48-
Paragraph "The following sections detail the configuration of the backup device $($SQLServer.Name)."
48+
Paragraph "The following sections detail the configuration of the backup device."
4949
foreach ($Item in $ItemInfo) {
5050
Section -Style NOTOCHeading5 -ExcludeFromTOC "$($Item.Name)" {
5151
$TableParams = @{
@@ -60,7 +60,7 @@ function Get-AbrWinSQLBackupDevice {
6060
}
6161
}
6262
} else {
63-
Paragraph "The following table summarises the configuration of the backup device within $($SQLServer.Name)."
63+
Paragraph "The following table summarises the configuration of the backup device."
6464
BlankLine
6565
$TableParams = @{
6666
Name = "Backup Devices"

Src/Private/Get-AbrWinSQLBuild.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Get-AbrWinSQLBuild {
2828
if ($InfoLevel.SQLServer -ge 1) {
2929
try {
3030
$Properties = Get-DbaInstanceProperty -SqlInstance $SQLServer | ForEach-Object { @{$_.Name = $_.Value } }
31-
$Build = Get-DbaBuild -SqlInstance $SQLServer
31+
$Build = Get-DbaBuild -SqlInstance $SQLServer -WarningAction SilentlyContinue
3232
if ($Properties) {
3333
Section -Style Heading3 'General Information' {
3434
Paragraph 'The following table details sql server Properties information'

Src/Private/Get-AbrWinSQLDatabase.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function Get-AbrWinSQLDatabase {
5353
'Status' = $SQLDB.Status
5454
'Is Accessible?' = ConvertTo-TextYN $SQLDB.IsAccessible
5555
'Recovery Model' = $SQLDB.RecoveryModel
56-
'Size' = Switch ([string]::IsNullOrEmpty($SQLDB.SizeM)) {
56+
'Size' = Switch ([string]::IsNullOrEmpty($SQLDB.SizeMB)) {
5757
$true { '--' }
5858
$false { "$($SQLDB.SizeMB) MB" }
5959
default { 'Unknown' }
@@ -80,7 +80,7 @@ function Get-AbrWinSQLDatabase {
8080
}
8181

8282
if ($InfoLevel.SQLServer -ge 2) {
83-
Paragraph "The following sections detail the configuration of the system databases within $($SQLServer.Name)."
83+
Paragraph "The following sections detail the configuration of the system databases."
8484
foreach ($SQLDB in $SQLDBInfo) {
8585
Section -Style NOTOCHeading5 -ExcludeFromTOC "$($SQLDB.Name)" {
8686
$TableParams = @{
@@ -95,7 +95,7 @@ function Get-AbrWinSQLDatabase {
9595
}
9696
}
9797
} else {
98-
Paragraph "The following table summarises the configuration of the system databases within $($SQLServer.Name)."
98+
Paragraph "The following table summarises the configuration of the system databases."
9999
BlankLine
100100
$TableParams = @{
101101
Name = "System Databases"
@@ -126,7 +126,7 @@ function Get-AbrWinSQLDatabase {
126126
'Status' = $SQLDB.Status
127127
'Is Accessible?' = ConvertTo-TextYN $SQLDB.IsAccessible
128128
'Recovery Model' = $SQLDB.RecoveryModel
129-
'Size' = Switch ([string]::IsNullOrEmpty($SQLDB.SizeM)) {
129+
'Size' = Switch ([string]::IsNullOrEmpty($SQLDB.SizeMB)) {
130130
$true { '--' }
131131
$false { "$($SQLDB.SizeMB) MB" }
132132
default { 'Unknown' }

Src/Private/Get-AbrWinSQLLogin.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Get-AbrWinSQLLogin {
3131
Section -Style Heading4 'Logins' {
3232
$ItemInfo = @()
3333
foreach ($Item in $SQLLogins) {
34-
$ServerRoles = try {Get-DbaServerRoleMember -SqlInstance $SQLServer -Login $Item.Name} catch {Out-Null}
34+
$ServerRoles = try { Get-DbaServerRoleMember -SqlInstance $SQLServer -Login $Item.Name } catch { Out-Null }
3535
try {
3636
$InObj = [Ordered]@{
3737
'Name' = $Item.Name
@@ -69,7 +69,7 @@ function Get-AbrWinSQLLogin {
6969
}
7070

7171
if ($InfoLevel.SQLServer -ge 2) {
72-
Paragraph "The following sections detail the configuration of the security login $($SQLServer.Name)."
72+
Paragraph "The following sections detail the configuration of the security login."
7373
foreach ($Item in $ItemInfo) {
7474
Section -Style NOTOCHeading5 -ExcludeFromTOC "$($Item.Name)" {
7575
$TableParams = @{
@@ -84,7 +84,7 @@ function Get-AbrWinSQLLogin {
8484
}
8585
}
8686
} else {
87-
Paragraph "The following table summarises the configuration of the security login within $($SQLServer.Name)."
87+
Paragraph "The following table summarises the configuration of the security login."
8888
BlankLine
8989
$TableParams = @{
9090
Name = "Logins"

Src/Private/Get-AbrWinSQLRole.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Get-AbrWinSQLRole {
5050
}
5151

5252
if ($InfoLevel.SQLServer -ge 2) {
53-
Paragraph "The following sections detail the configuration of the security roles $($SQLServer.Name)."
53+
Paragraph "The following sections detail the configuration of the security roles."
5454
foreach ($Item in $ItemInfo) {
5555
Section -Style NOTOCHeading5 -ExcludeFromTOC "$($Item.Name)" {
5656
$TableParams = @{
@@ -65,7 +65,7 @@ function Get-AbrWinSQLRole {
6565
}
6666
}
6767
} else {
68-
Paragraph "The following table summarises the configuration of the security role within $($SQLServer.Name)."
68+
Paragraph "The following table summarises the configuration of the security role."
6969
BlankLine
7070
$TableParams = @{
7171
Name = "Roles"

Src/Public/Invoke-AsBuiltReport.Microsoft.Windows.ps1

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ function Invoke-AsBuiltReport.Microsoft.Windows {
2222
[PSCredential] $Credential
2323
)
2424

25-
Write-PScriboMessage -IsWarning "Please refer to the AsBuiltReport.Microsoft.Windows github website for more detailed information about this project."
26-
Write-PScriboMessage -IsWarning "Do not forget to update your report configuration file after each new release."
27-
Write-PScriboMessage -IsWarning "Documentation: https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.Windows"
28-
Write-PScriboMessage -IsWarning "Issues or bug reporting: https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.Windows/issues"
25+
Write-PScriboMessage -Plugin "Module" -IsWarning "Please refer to the AsBuiltReport.Microsoft.Windows github website for more detailed information about this project."
26+
Write-PScriboMessage -Plugin "Module" -IsWarning "Do not forget to update your report configuration file after each new release."
27+
Write-PScriboMessage -Plugin "Module" -IsWarning "Documentation: https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.Windows"
28+
Write-PScriboMessage -Plugin "Module" -IsWarning "Issues or bug reporting: https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.Windows/issues"
2929

3030
Try {
3131
$InstalledVersion = Get-Module -ListAvailable -Name AsBuiltReport.Microsoft.Windows -ErrorAction SilentlyContinue | Sort-Object -Property Version -Descending | Select-Object -First 1 -ExpandProperty Version
3232

3333
if ($InstalledVersion) {
34-
Write-PScriboMessage -IsWarning "AsBuiltReport.Microsoft.Windows $($InstalledVersion.ToString()) is currently installed."
34+
Write-PScriboMessage -Plugin "Module" -IsWarning "AsBuiltReport.Microsoft.Windows $($InstalledVersion.ToString()) is currently installed."
3535
$LatestVersion = Find-Module -Name AsBuiltReport.Microsoft.Windows -Repository PSGallery -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Version
3636
if ($LatestVersion -gt $InstalledVersion) {
37-
Write-PScriboMessage -IsWarning "AsBuiltReport.Microsoft.Windows $($LatestVersion.ToString()) is available."
38-
Write-PScriboMessage -IsWarning "Run 'Update-Module -Name AsBuiltReport.Microsoft.Windows -Force' to install the latest version."
37+
Write-PScriboMessage -Plugin "Module" -IsWarning "AsBuiltReport.Microsoft.Windows $($LatestVersion.ToString()) is available."
38+
Write-PScriboMessage -Plugin "Module" -IsWarning "Run 'Update-Module -Name AsBuiltReport.Microsoft.Windows -Force' to install the latest version."
3939
}
4040
}
4141
} Catch {
@@ -342,13 +342,18 @@ function Invoke-AsBuiltReport.Microsoft.Windows {
342342
}
343343

344344
if ($InfoLevel.SQLServer -ge 1 -and $OSType.Value -ne 'WorkStation') {
345-
$Status = Invoke-Command -Session $TempPssSession -ScriptBlock { Get-Service 'MSSQLSERVER' -ErrorAction SilentlyContinue }
345+
$Status = Invoke-Command -Session $TempPssSession -ScriptBlock { Get-Service 'MSSQL*' -ErrorAction SilentlyContinue }
346346
if ($Status.Status -eq "Running") {
347347
try {
348-
$script:SQLServer = Connect-DbaInstance -SqlInstance $System -TrustServerCertificate -SqlCredential $Credential
348+
if ($Options.SQLLogin) {
349+
$SQLCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Options.SQLUserName, (ConvertTo-SecureString -Force $Options.SQLSecurePassword)
350+
$script:SQLServer = Connect-DbaInstance -SqlInstance $System -TrustServerCertificate -SqlCredential $SQLCredential
351+
} else {
352+
$script:SQLServer = Connect-DbaInstance -SqlInstance $System -TrustServerCertificate -SqlCredential $Credential
353+
}
349354
if ($SQLServer) {
350355
Section -Style Heading2 "SQL Server Configuration" {
351-
Paragraph 'The following table details the SQL Server settings'
356+
Paragraph "The following table details the SQL Server configuration from $($SQLServer.Name)."
352357
BlankLine
353358
# SQL Server Build Information
354359
Get-AbrWinSQLBuild

0 commit comments

Comments
 (0)