Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Jul 16, 2024
2 parents dfae1fd + 2ca852e commit 8bce0df
Show file tree
Hide file tree
Showing 41 changed files with 238 additions and 5,446 deletions.
34 changes: 33 additions & 1 deletion bin/dbatools-buildref-index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"LastUpdated": "2024-06-13T00:00:00",
"LastUpdated": "2024-07-10T00:00:00",
"Data": [
{
"Version": "8.0.47",
Expand Down Expand Up @@ -4115,6 +4115,10 @@
"Version": "13.0.6435",
"KBList": "5029186"
},
{
"Version": "13.0.6441",
"KBList": "5040946"
},
{
"Version": "13.0.7000",
"KBList": "5014242"
Expand All @@ -4131,6 +4135,10 @@
"Version": "13.0.7029",
"KBList": "5029187"
},
{
"Version": "13.0.7037",
"KBList": "5040944"
},
{
"Version": "14.0.1",
"Name": "2017"
Expand Down Expand Up @@ -4192,6 +4200,10 @@
"Version": "14.0.2052",
"KBList": "5029375"
},
{
"Version": "14.0.2056",
"KBList": "5040942"
},
{
"CU": "CU1",
"Version": "14.0.3006",
Expand Down Expand Up @@ -4383,6 +4395,10 @@
"Version": "14.0.3465",
"KBList": "5029376"
},
{
"Version": "14.0.3471",
"KBList": "5040940"
},
{
"Version": "15.0.1000",
"Name": "2019"
Expand Down Expand Up @@ -4428,6 +4444,10 @@
"Version": "15.0.2110",
"KBList": "5035434"
},
{
"Version": "15.0.2116",
"KBList": "5040986"
},
{
"CU": "CU1",
"Version": "15.0.4003",
Expand Down Expand Up @@ -4584,6 +4604,10 @@
"Version": "15.0.4375",
"KBList": "5037331"
},
{
"Version": "15.0.4382",
"KBList": "5040948"
},
{
"Version": "16.0.100",
"Name": "2022"
Expand Down Expand Up @@ -4617,6 +4641,10 @@
"Version": "16.0.1115",
"KBList": "5035432"
},
{
"Version": "16.0.1121",
"KBList": "5040936"
},
{
"CU": "CU1",
"Version": "16.0.4003",
Expand Down Expand Up @@ -4693,6 +4721,10 @@
"CU": "CU13",
"Version": "16.0.4125",
"KBList": "5036432"
},
{
"Version": "16.0.4131",
"KBList": "5040939"
}
]
}
2 changes: 1 addition & 1 deletion bin/diagnosticquery/SQLServerDiagnosticQueries_2014.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2014 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 14, 2024
-- Last Modified: July 9, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down
2 changes: 1 addition & 1 deletion bin/diagnosticquery/SQLServerDiagnosticQueries_2016.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2016 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 14, 2024
-- Last Modified: July 9, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down
7 changes: 4 additions & 3 deletions bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2016 SP2 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 14, 2024
-- Last Modified: July 9, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -89,8 +89,9 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- 13.0.6404.1 SP3 Hotfix 10/28/2021 https://support.microsoft.com/en-us/topic/kb5006943-on-demand-hotfix-update-package-for-sql-server-2016-sp3-94de2975-cd7d-47ed-b003-5d7daf4e2caf
-- 13.0.6419.1 SP3 + GDR 6/14/2022 https://support.microsoft.com/en-us/topic/kb5014355-description-of-the-security-update-for-sql-server-2016-sp3-gdr-june-14-2022-bb5097a0-f8f1-4d2c-bfe1-af069ca3cc59
-- 13.0.7016.1 Azure Connect Pack + GDR 6/14/2022 https://support.microsoft.com/en-us/topic/kb5015371-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-june-14-2022-d809657e-15a9-48fe-bd19-a8864ac5d3a4
-- 13.0.7024.30 SP3 + GDR 2/14/2023 https://support.microsoft.com/en-us/topic/kb5021128-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-february-14-2023-89e54794-460a-41bd-981f-998290e7d46e
-- 13.0.7029.3 SP3 + GDR 10/10/2023 https://support.microsoft.com/en-us/topic/kb5029187-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-october-10-2023-e5541468-f243-4000-872c-ac782cfad99f
-- 13.0.7024.30 Azure Connect Pack + GDR 2/14/2023 https://support.microsoft.com/en-us/topic/kb5021128-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-february-14-2023-89e54794-460a-41bd-981f-998290e7d46e
-- 13.0.7029.3 Azure Connect Pack + GDR 10/10/2023 https://support.microsoft.com/en-us/topic/kb5029187-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-october-10-2023-e5541468-f243-4000-872c-ac782cfad99f
-- 13.0.7037.1 Azure Connect Pack + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040944-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-july-9-2024-72b636c9-0619-4c44-b263-f3d7478bcd75

-- How to determine the version, edition and update level of SQL Server and its components
-- https://bit.ly/2oAjKgW
Expand Down
3 changes: 2 additions & 1 deletion bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2017 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 14, 2024
-- Last Modified: July 10, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -106,6 +106,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- 14.0.3456.2 CU31 9/20/2022 https://support.microsoft.com/en-us/topic/kb5016884-cumulative-update-31-for-sql-server-2017-6aa612d0-c97e-4c54-a41f-37f53777ba4c
-- 14.0.3460.9 CU31 + GDR 2/14/2023 https://support.microsoft.com/en-us/topic/kb5021126-description-of-the-security-update-for-sql-server-2017-cu31-february-14-2023-2867280f-e66f-4598-a2f1-3d301e367683
-- 14.0.3465.1 CU31 + GDR 10/10/2023 https://support.microsoft.com/en-us/topic/kb5029376-description-of-the-security-update-for-sql-server-2017-cu31-october-10-2023-ce23ddf7-b79e-4ba7-ba9d-2679f23a1ad8
-- 14.0.3471.2 CU31 + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040940-description-of-the-security-update-for-sql-server-2017-cu31-july-9-2024-bff7ab26-e882-4419-aebb-30356125f5c9

-- How to determine the version, edition and update level of SQL Server and its components
-- https://bit.ly/2oAjKgW
Expand Down
3 changes: 2 additions & 1 deletion bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2019 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 14, 2024
-- Last Modified: July 9, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -102,6 +102,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- 15.0.4360.2 CU25 + GDR 4/9/2024 https://support.microsoft.com/en-us/topic/kb5036335-description-of-the-security-update-for-sql-server-2019-cu25-april-9-2024-eb3571d0-62ee-445e-9681-5715caf9bbc2
-- 15.0.4365.2 CU26 4/11/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate26
-- 15.0.4375.4 CU27 6/13/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate27
-- 15.0.8382.1 CU27 + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040948-description-of-the-security-update-for-sql-server-2019-cu27-july-9-2024-6447dc00-9f1b-484c-9d3d-9e1f1b9f915c

-- How to determine the version, edition and update level of SQL Server and its components
-- https://bit.ly/2oAjKgW
Expand Down
3 changes: 2 additions & 1 deletion bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2022 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 14, 2024
-- Last Modified: July 10, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -80,6 +80,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- 16.0.4115.5 CU12 3/14/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate12
-- 16.0.4120.1 CU12 + GDR 4/9/2024 https://support.microsoft.com/en-us/topic/kb5036343-description-of-the-security-update-for-sql-server-2022-cu12-april-9-2024-e11a0715-435f-42be-89ff-4b3d8f9734fc
-- 16.0.4125.3 CU13 5/16/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate13
-- 16.0.4131.2 CU13 + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040939-description-of-the-security-update-for-sql-server-2022-cu13-july-9-2024-16a61a81-926c-46a5-b6c0-edbca541f2f6

-- What's new in SQL Server 2022 (16.x)
-- https://bit.ly/3MJEjR1
Expand Down
2 changes: 1 addition & 1 deletion dbatools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'dbatools.psm1'

# Version number of this module.
ModuleVersion = '2.1.19'
ModuleVersion = '2.1.20'

# ID used to uniquely identify this module
GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'
Expand Down
21 changes: 17 additions & 4 deletions public/Backup-DbaDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,15 @@ function Backup-DbaDatabase {

if (Test-Bound 'EncryptionAlgorithm') {
if (!((Test-Bound 'EncryptionCertificate') -xor (Test-Bound 'EncryptionKey'))) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message 'EncryptionCertifcate and EncryptionKey are mutually exclusive, only provide on of them'
return
} else {
$encryptionOptions = New-Object Microsoft.SqlServer.Management.Smo.BackupEncryptionOptions
if (Test-Bound 'EncryptionCertificate') {
$tCertCheck = Get-DbaDbCertificate -SqlInstance $server -Database master -Certificate $EncryptionCertificate
if ($null -eq $tCertCheck) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "Certificate $EncryptionCertificate does not exist on $server so cannot be used for backups"
return
} else {
Expand All @@ -415,6 +417,7 @@ function Backup-DbaDatabase {
# Should not end up here until Key encryption in implemented
$tKeyCheck = Get-DbaDbAsymmetricKey -SqlInstance $server -Database master -Name $EncrytptionKey
if ($null -eq $tKeyCheck) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "AsymmetricKey $Encryptionkey does not exist on $server so cannot be used for backups"
return
} else {
Expand All @@ -441,13 +444,14 @@ function Backup-DbaDatabase {
}

if (($MaxTransferSize % 64kb) -ne 0 -or $MaxTransferSize -gt 4mb) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "MaxTransferSize value must be a multiple of 64kb and no greater than 4MB"
return
}

if ($BlockSize) {
if ($BlockSize -notin (0.5kb, 1kb, 2kb, 4kb, 8kb, 16kb, 32kb, 64kb)) {

Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "Block size must be one of 0.5kb,1kb,2kb,4kb,8kb,16kb,32kb,64kb"
return
}
Expand All @@ -469,6 +473,7 @@ function Backup-DbaDatabase {
if (Get-DbaCredential -SqlInstance $server -Name $credentialName) {
Write-Message -Message "Found a SAS backup credential" -Level Verbose
} else {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "You must provide the credential name for the Azure Storage Account"
return
}
Expand All @@ -488,14 +493,17 @@ function Backup-DbaDatabase {
}

if ($dbName -eq "tempdb") {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "Backing up tempdb not supported" -Continue
}

if ('Normal' -notin ($db.Status -split ',')) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "Database status not Normal. $dbName skipped." -Continue
}

if ($db.DatabaseSnapshotBaseName) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "Backing up snapshots not supported. $dbName skipped." -Continue
}

Expand All @@ -511,6 +519,7 @@ function Backup-DbaDatabase {
if ($dbRecovery -eq 'Simple' -and $Type -eq 'Log') {
$failreason = "$db is in simple recovery mode, cannot take log backup"
$failures += $failreason
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "$failreason" -Continue -Target $db
}

Expand All @@ -520,6 +529,7 @@ function Backup-DbaDatabase {
if ($Type -notin @("Database", "Full") -and $lastfull -eq 1) {
$failreason = "$db does not have an existing full backup, cannot take log or differentialbackup"
$failures += $failreason
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "$failreason" -Continue -Target $db
}

Expand Down Expand Up @@ -562,6 +572,7 @@ function Backup-DbaDatabase {
$backup.CompressionOption = [Microsoft.SqlServer.Management.Smo.BackupCompressionOptions]::Off
}
} elseif ($server.Edition -like 'Express*' -or ($server.VersionMajor -eq 10 -and $server.VersionMinor -eq 0 -and $server.Edition -notlike '*enterprise*') -or $server.VersionMajor -lt 10) {
Write-Progress -Id $topProgressId -Activity 'Backup' -Completed
Stop-Function -Message "Compression is not supported with this version/edition of Sql Server" -Continue -Target $db
} else {
Write-Message -Level Verbose -Message "Compression enabled"
Expand Down Expand Up @@ -758,7 +769,7 @@ function Backup-DbaDatabase {
if ($OutputScriptOnly -ne $True) {
$backup.SqlBackup($server)
$script = $backup.Script($server)
Write-Progress -Id $ProgressId -Activity "Backing up database $dbName to $backupfile" -Status "Complete" -Completed
Write-Progress -Id $ProgressId -Activity "Backing up database $dbName to $backupfile" -Completed
$BackupComplete = $true
if ($server.VersionMajor -eq '8') {
$HeaderInfo = Get-BackupAncientHistory -SqlInstance $server -Database $dbName
Expand Down Expand Up @@ -826,13 +837,15 @@ function Backup-DbaDatabase {
$HeaderInfo | Add-Member -Type NoteProperty -Name Verified -Value $Verified
} else {
$backup.Script($server)
Write-Progress -Id $ProgressId -Activity "Backing up database $dbName to $backupfile" -Completed
}
}
} catch {
if ($NoRecovery -and ($_.Exception.InnerException.InnerException.InnerException -like '*cannot be opened. It is in the middle of a restore.')) {
Write-Message -Message "Exception thrown by db going into restoring mode due to recovery" -Leve Verbose
Write-Message -Message "Exception thrown by db going into restoring mode due to recovery" -Level Verbose
} else {
Write-Progress -Id $ProgressId -Activity "Backup" -Status "Failed" -Completed
Write-Progress -Id $ProgressId -Activity "Backup" -Completed
Write-Progress -Id $topProgressId -Activity "Backup" -Completed
Stop-Function -message "Backup of [$dbName] failed" -ErrorRecord $_ -Target $dbName -Continue
$BackupComplete = $false
}
Expand Down
1 change: 1 addition & 0 deletions public/Connect-DbaInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ function Connect-DbaInstance {
if (-not $server.IsAzure) {
Add-Member -InputObject $server -NotePropertyName IsAzure -NotePropertyValue $isAzure -Force
Add-Member -InputObject $server -NotePropertyName DbaInstanceName -NotePropertyValue $instance.InstanceName -Force
Add-Member -InputObject $server -NotePropertyName SqlInstance -NotePropertyValue $server.DomainInstanceName -Force
Add-Member -InputObject $server -NotePropertyName NetPort -NotePropertyValue $instance.Port -Force
Add-Member -InputObject $server -NotePropertyName ConnectedAs -NotePropertyValue $server.ConnectionContext.TrueLogin -Force
Write-Message -Level Debug -Message "We added IsAzure = '$($server.IsAzure)', DbaInstanceName = instance.InstanceName = '$($server.DbaInstanceName)', SqlInstance = server.DomainInstanceName = '$($server.SqlInstance)', NetPort = instance.Port = '$($server.NetPort)', ConnectedAs = server.ConnectionContext.TrueLogin = '$($server.ConnectedAs)'"
Expand Down
6 changes: 4 additions & 2 deletions public/Get-DbaDbStoredProcedure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ function Get-DbaDbStoredProcedure {
$InputObject = Get-DbaDatabase -SqlInstance $SqlInstance -SqlCredential $SqlCredential -Database $Database -ExcludeDatabase $ExcludeDatabase
}

$ExcludeSystemSpIsBound = Test-Bound -ParameterName ExcludeSystemSp

foreach ($db in $InputObject) {
if (!$db.IsAccessible) {
Write-Message -Level Warning -Message "Database $db is not accessible. Skipping."
Expand Down Expand Up @@ -182,7 +184,7 @@ function Get-DbaDbStoredProcedure {
}

foreach ($proc in $procs) {
if ( (Test-Bound -ParameterName ExcludeSystemSp) -and $proc.IsSystemObject ) {
if ($ExcludeSystemSpIsBound -and $proc.IsSystemObject ) {
continue
}

Expand All @@ -198,4 +200,4 @@ function Get-DbaDbStoredProcedure {
}
}
}
}
}
2 changes: 1 addition & 1 deletion public/Get-DbaDbUdf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function Get-DbaDbUdf {
Write-Message -Message "No User Defined Functions exist in the $db database on $instance" -Target $db -Level Verbose
continue
}
if (Test-Bound -ParameterName ExcludeSystemUdf) {
if ($ExcludeSystemUdf) {
$userDefinedFunctions = $userDefinedFunctions | Where-Object IsSystemObject -eq $false
}

Expand Down
2 changes: 1 addition & 1 deletion public/Get-DbaDbUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function Get-DbaDbUser {
Write-Message -Message "No users exist in the $db database on $instance" -Target $db -Level Verbose
continue
}
if (Test-Bound -ParameterName ExcludeSystemUser) {
if ($ExcludeSystemUser) {
$users = $users | Where-Object { $_.IsSystemObject -eq $false }
}
if (Test-Bound -ParameterName User) {
Expand Down
2 changes: 1 addition & 1 deletion public/Get-DbaExternalProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function Get-DbaExternalProcess {
foreach ($computer in $ComputerName) {
try {
$sqlpid = (Get-DbaCmObject -ComputerName $computer -Credential $Credential -ClassName win32_process | Where-Object ProcessName -eq "sqlservr.exe").ProcessId
$processes = Get-DbaCmObject -ComputerName $computer -Credential $Credential -ClassName win32_process | Where-Object ParentProcessId -eq $sqlpid
$processes = Get-DbaCmObject -ComputerName $computer -Credential $Credential -ClassName win32_process | Where-Object ParentProcessId -in $sqlpid

foreach ($process in $processes) {
[PSCustomObject]@{
Expand Down
Loading

0 comments on commit 8bce0df

Please sign in to comment.