Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed May 22, 2024
2 parents 6c7cb4b + afc6cd2 commit cd52bf9
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 63 deletions.
Binary file modified bin/dbatools-index.json
Binary file not shown.
4 changes: 3 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: May 2, 2024
-- Last Modified: May 17, 2024
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -79,6 +79,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- 16.0.4105.2 CU11 1/11/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate11
-- 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

-- What's new in SQL Server 2022 (16.x)
-- https://bit.ly/3MJEjR1
Expand Down Expand Up @@ -195,6 +196,7 @@ ORDER BY name OPTION (RECOMPILE);
-- Data processed monthly limit in TB SQL On-demand data processed monthly limit in TB
-- Data processed weekly limit in TB SQL On-demand data processed weekly limit in TB
-- hardware offload config Offload processing to specialized hardware
-- max RPC request params (KB) Maximum memory for RPC request parameters (kBytes) (added in CU13)
-- openrowset auto_create_statistics Enable or disable auto create statistics for openrowset sources.
-- suppress recovery model errors Return warning instead of error for unsupported ALTER DATABASE SET RECOVERY command

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.15'
ModuleVersion = '2.1.16'

# ID used to uniquely identify this module
GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'
Expand Down
12 changes: 6 additions & 6 deletions public/Backup-DbaDbMasterKey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ function Backup-DbaDbMasterKey {
}

$fileinstance = $instance.ToString().Replace('\', '$')
$fullKeyName = Join-DbaPath -SqlInstance $server -Path $actualPath -ChildPath "$fileinstance-$dbname-masterkey"
$filename = Join-DbaPath -SqlInstance $server -Path $actualPath -ChildPath "$fileinstance-$dbname-masterkey.key"

# if the base file name exists, then default to old style of appending a timestamp
if (Test-DbaPath -SqlInstance $server -Path "$fullKeyName.key") {
$fullKeyName = "$fullKeyName-$time"
if (Test-DbaPath -SqlInstance $server -Path $filename) {
$filename = Join-DbaPath -SqlInstance $server -Path $actualPath -ChildPath "$fileinstance-$dbname-masterkey-$time.key"
}

if ($Pscmdlet.ShouldProcess($instance, "Backing up master key to $fullKeyName")) {
if ($Pscmdlet.ShouldProcess($instance, "Backing up master key to $filename")) {
try {
$masterkey.Export("$fullKeyName.key", ($SecurePassword | ConvertFrom-SecurePass))
$masterkey.Export($filename, ($SecurePassword | ConvertFrom-SecurePass))
$status = "Success"
} catch {
$status = "Failure"
Expand All @@ -168,7 +168,7 @@ function Backup-DbaDbMasterKey {
Add-Member -Force -InputObject $masterkey -MemberType NoteProperty -Name SqlInstance -value $server.DomainInstanceName
Add-Member -Force -InputObject $masterkey -MemberType NoteProperty -Name Database -value $dbName
Add-Member -Force -InputObject $masterkey -MemberType NoteProperty -Name DatabaseID -value $db.ID
Add-Member -Force -InputObject $masterkey -MemberType NoteProperty -Name Filename -value $fullKeyName
Add-Member -Force -InputObject $masterkey -MemberType NoteProperty -Name Filename -value $filename
Add-Member -Force -InputObject $masterkey -MemberType NoteProperty -Name Status -value $status

Select-DefaultView -InputObject $masterkey -Property ComputerName, InstanceName, SqlInstance, Database, 'Filename as Path', Status
Expand Down
17 changes: 11 additions & 6 deletions public/ConvertTo-DbaDataTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ function ConvertTo-DbaDataTable {
}
}
$specialType = 'Size'
} elseif ($type -eq 'Dataplat.Dbatools.Utility.DbaDateTime') {
$special = $true
$value = [System.DateTime]$value.DateTime
$type = 'System.DateTime'
$specialType = 'DateTime'
} elseif ($type -eq 'Dataplat.Dbatools.Utility.DbaDateTime[]') {
if (-not ($null -eq $value)) {
$special = $true
$value = $value
$type = 'System.String'
$specialType = 'String'
}
} elseif (-not ($type -in $types)) {
# All types which are not found in the array will be converted into strings.
# In this way we don't ignore it completely and it will be clear in the end why it looks as it does.
Expand Down Expand Up @@ -204,7 +206,7 @@ function ConvertTo-DbaDataTable {
[CmdletBinding()]
param (
$Value,
[ValidateSet('Timespan', 'Size')]
[ValidateSet('Timespan', 'Size', 'DateTime', 'String')]
[string]$Type,
[string]$SizeType,
[string]$TimeSpanType
Expand All @@ -225,6 +227,9 @@ function ConvertTo-DbaDataTable {
'DateTime' {
return [System.DateTime]$Value.DateTime
}
'String' {
return ($Value | Foreach-Object { $_.ToString() }) -join ', '
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions public/Install-DbaInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ function Install-DbaInstance {
[PSCredential]$FTCredential,
[PSCredential]$PBEngineCredential,
[string]$SaveConfiguration,
[Alias('InstantFileInitialization', 'IFI')]
[switch]$PerformVolumeMaintenanceTasks,
[switch]$Restart,
[switch]$NoPendingRenameCheck = (Get-DbatoolsConfigValue -Name 'OS.PendingRename' -Fallback $false),
Expand Down Expand Up @@ -701,6 +702,10 @@ function Install-DbaInstance {
$configNode.SQLTEMPDBFILECOUNT = $cores
}
}
if ($canonicVersion -ge '13.0' -and $PerformVolumeMaintenanceTasks) {
$configNode.SQLSVCINSTANTFILEINIT = 'True'
$PerformVolumeMaintenanceTasks = $false
}
if ($canonicVersion -ge '16.0') {
$null = $configNode.Remove('X86')
}
Expand Down
16 changes: 8 additions & 8 deletions public/Invoke-DbaDbLogShipping.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -928,20 +928,20 @@ function Invoke-DbaDbLogShipping {
if (-not $IsDestinationLocal -and $DestinationCredential) {
Invoke-Command2 -ComputerName $DestinationServerName -Credential $DestinationCredential -ScriptBlock {
Write-Message -Message "Creating copy destination folder $CopyDestinationFolder" -Level Verbose
New-Item -Path $CopyDestinationFolder -ItemType Directory -Credential $DestinationCredential -Force:$Force | Out-Null
$null = New-Item -Path $CopyDestinationFolder -ItemType Directory -Force:$Force
}
}
# If the server is local and the credential is set
elseif ($DestinationCredential) {
Invoke-Command2 -Credential $DestinationCredential -ScriptBlock {
Write-Message -Message "Creating copy destination folder $CopyDestinationFolder" -Level Verbose
New-Item -Path $CopyDestinationFolder -ItemType Directory -Credential $DestinationCredential -Force:$Force | Out-Null
$null = New-Item -Path $CopyDestinationFolder -ItemType Directory -Force:$Force
}
}
# If the server is local and the credential is not set
else {
Write-Message -Message "Creating copy destination folder $CopyDestinationFolder" -Level Verbose
New-Item -Path $CopyDestinationFolder -Force:$Force -ItemType Directory | Out-Null
$null = New-Item -Path $CopyDestinationFolder -ItemType Directory -Force:$Force
}
Write-Message -Message "Copy destination $CopyDestinationFolder created." -Level Verbose
} catch {
Expand All @@ -963,7 +963,7 @@ function Invoke-DbaDbLogShipping {
# Try to create the copy destination on the local server
try {
Write-Message -Message "Creating copy destination folder $CopyDestinationFolder" -Level Verbose
New-Item $CopyDestinationFolder -ItemType Directory -Credential $DestinationCredential -Force:$Force | Out-Null
$null = New-Item -Path $CopyDestinationFolder -ItemType Directory -Force:$Force
Write-Message -Message "Copy destination $CopyDestinationFolder created." -Level Verbose
} catch {
$setupResult = "Failed"
Expand Down Expand Up @@ -1090,7 +1090,7 @@ function Invoke-DbaDbLogShipping {

Invoke-Command2 -Credential $SourceCredential -ScriptBlock {
Write-Message -Message "Creating backup folder $DatabaseSharedPath" -Level Verbose
$null = New-Item -Path $DatabaseSharedPath -ItemType Directory -Credential $SourceCredential -Force:$Force
$null = New-Item -Path $DatabaseSharedPath -ItemType Directory -Force:$Force
}
} catch {
$setupResult = "Failed"
Expand Down Expand Up @@ -1193,7 +1193,7 @@ function Invoke-DbaDbLogShipping {
try {
Invoke-Command2 -Credential $DestinationCredential -ScriptBlock {
Write-Message -Message "Creating data folder $DatabaseRestoreDataFolder" -Level Verbose
$null = New-Item -Path $DatabaseRestoreDataFolder -ItemType Directory -Credential $DestinationCredential -Force:$Force
$null = New-Item -Path $DatabaseRestoreDataFolder -ItemType Directory -Force:$Force
}
} catch {
$setupResult = "Failed"
Expand All @@ -1213,7 +1213,7 @@ function Invoke-DbaDbLogShipping {

Invoke-Command2 -Credential $DestinationCredential -ScriptBlock {
Write-Message -Message "Restore log folder $DatabaseRestoreLogFolder not found. Trying to create it.." -Level Verbose
$null = New-Item -Path $DatabaseRestoreLogFolder -ItemType Directory -Credential $DestinationCredential -Force:$Force
$null = New-Item -Path $DatabaseRestoreLogFolder -ItemType Directory -Force:$Force
}
} catch {
$setupResult = "Failed"
Expand Down Expand Up @@ -1308,7 +1308,7 @@ function Invoke-DbaDbLogShipping {
try {
Invoke-Command2 -Credential $DestinationCredential -ScriptBlock {
Write-Message -Message "Copy destination folder $DatabaseCopyDestinationFolder not found. Trying to create it.. ." -Level Verbose
$null = New-Item -Path $DatabaseCopyDestinationFolder -ItemType Directory -Credential $DestinationCredential -Force:$Force
$null = New-Item -Path $DatabaseCopyDestinationFolder -ItemType Directory -Force:$Force
}
} catch {
$setupResult = "Failed"
Expand Down
5 changes: 5 additions & 0 deletions public/Write-DbaDbTableData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ function Write-DbaDbTableData {
$columns = $DataTable.Table.Columns
}

if ($null -eq $columns) {
Stop-Function -Message "Unable to get column definition from input data, so AutoCreateTable is not possible"
return
}

foreach ($column in $columns) {
$sqlColumnName = $column.ColumnName

Expand Down
Loading

0 comments on commit cd52bf9

Please sign in to comment.