Skip to content
Permalink
Browse files

0.9.804

  • Loading branch information...
potatoqualitee committed Apr 14, 2019
1 parent a1078c3 commit 3184e2dc624ae91cf0c1bf6d943ad8f57d44658a
}
}

$destServerOperators = $destServer.JobServer.Operators

foreach ($serverAlert in $serverAlerts) {
$alertName = $serverAlert.name
$copyAgentAlertStatus = [pscustomobject]@{
continue
}

if ($sourceLogin.LoginType -like 'Window*' -and $destServer.DatabaseEngineEdition -eq 'SqlManagedInstance' ) {
Write-Message -Level Verbose -Message "$sourceLogin is a Windows login, not supported on a SQL Managed Instance"
$copyLoginStatus.Status = "Skipped"
$copyLoginStatus.Notes = "$sourceLogin is a Windows login, not supported on a SQL Managed Instance"
$copyLoginStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
continue
}

$serverName = Resolve-NetBiosName $sourceServer

$currentLogin = $sourceServer.ConnectionContext.truelogin
.PARAMETER LastLsn
Specifies a minimum LSN to use in filtering backup history. Only backups with an LSN greater than this value will be returned, which helps speed the retrieval process.

.PARAMETER IncludeMirror
By default mirrors of backups are not returned, this switch will cause them to be returned

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
[string[]]$DeviceType,
[switch]$Raw,
[bigint]$LastLsn,
[switch]$IncludeMirror,
[ValidateSet("Full", "Log", "Differential", "File", "Differential File", "Partial Full", "Partial Differential")]
[string[]]$Type,
[Alias('Silent')]
if ($true -ne $IncludeCopyOnly) {
$whereCopyOnly = " AND is_copy_only='0' "
}
if ($true -ne $IncludeMirror) {
$whereMirror = " AND mediafamily.mirror='0' "
}
if ($deviceTypeFilter) {
$devTypeFilterWhere = "AND mediafamily.device_type $deviceTypeFilterRight"
}
$devTypeFilterWhere
$sinceSqlFilter
$recoveryForkSqlFilter
$whereMirror
) AS a
WHERE a.BackupSetRank = 1
ORDER BY a.Type;
}
}

# Check of the relative FrequencyInterval value is of type string and set the integer value
# Check if the relative FrequencyInterval value is of type string and set the integer value
[int]$FrequencyRelativeInterval =
switch ($FrequencyRelativeInterval) {
"First" { 1 }
"Fourth" { 8 }
"Last" { 16 }
"Unused" { 0 }
default {0}
default { 0 }
}

# Check if the interval is valid

# Create the interval to hold the value(s)
switch ($FrequencyInterval) {
"EveryDay" { $Interval = 1}
default {$Interval = 1 }
"EveryDay" { $Interval = 1 }
default { $Interval = 1 }
}

}
"Saturday" { $Interval += 64 }
"Weekdays" { $Interval = 62 }
"Weekend" { $Interval = 65 }
"EveryDay" {$Interval = 127 }
"EveryDay" { $Interval = 127 }
1 { $Interval += 1 }
2 { $Interval += 2 }
4 { $Interval += 4 }
64 { $Interval += 64 }
62 { $Interval = 62 }
65 { $Interval = 65 }
127 {$Interval = 127 }
127 { $Interval = 127 }
default { $Interval = 0 }
}
}
foreach ($Item in $FrequencyInterval) {
$FrequencyInterval
switch ($Item) {
{[int]$_ -ge 1 -and [int]$_ -le 31} { $Interval = [int]$Item }
{ [int]$_ -ge 1 -and [int]$_ -le 31 } { $Interval = [int]$Item }
}
}

[int]$BackupPriority = 50,
[ValidateSet('AllowAllConnections', 'AllowReadWriteConnections')]
[string]$ConnectionModeInPrimaryRole = 'AllowAllConnections',
[ValidateSet('AllowAllConnections', 'AllowNoConnections', 'AllowReadIntentConnectionsOnly')]
[ValidateSet('AllowAllConnections', 'AllowNoConnections', 'AllowReadIntentConnectionsOnly', 'No', 'Read-intent only', 'Yes')]
[string]$ConnectionModeInSecondaryRole = 'AllowAllConnections',
[ValidateSet('Automatic', 'Manual')]
[string]$SeedingMode = 'Manual',
return
}

if ($ConnectionModeInSecondaryRole) {
$ConnectionModeInSecondaryRole =
switch ($ConnectionModeInSecondaryRole) {
"No" { "AllowNoConnections" }
"Read-intent only" { "AllowReadIntentConnectionsOnly" }
"Yes" { "AllowAllConnections" }
default { $ConnectionModeInSecondaryRole }
}
}

try {
$server = Connect-SqlInstance -SqlInstance $Primary -SqlCredential $PrimarySqlCredential
} catch {
}

if ($server.VersionMajor -ge 13) {
$replicaparams += @{SeedingMode = $SeedingMode}
$replicaparams += @{SeedingMode = $SeedingMode }
}

$null = Add-DbaAgReplica @replicaparams -EnableException -SqlInstance $server
}
}

if ($true -eq $IgnoreFull -and $true -eq $IgnoreDiffs) {
#Set a Fake starting LSN
}

if ($false -eq $IgnoreLogs) {
$FilteredLogs = $DatabaseHistory | Where-Object {$_.Type -in ('Log', 'Transaction Log') -and $_.Start -le $RestoreTime -and $_.LastLSN -ge $LogBaseLsn -and $_.FirstLSN -ne $_.LastLSN} | Sort-Object -Property LastLsn, FirstLsn
$GroupedLogs = $FilteredLogs | Group-Object -Property LastLSN, FirstLSN
$GroupedLogs = $FilteredLogs | Group-Object -Property BackupSetID
ForEach ($Group in $GroupedLogs) {
$Log = $DatabaseHistory | Where-Object { $_.BackupSetID -eq $Group.group[0].BackupSetID } | select-object -First 1
if ($Log.FullName) {
$Log.FullName = ($DatabaseHistory | Where-Object { $_.BackupSetID -eq $Group.group[0].BackupSetID }).Fullname
} else {
Stop-Function -Message "Fullname property not found. This could mean that a full backup could not be found or the command must be re-run with the -Continue switch."
return
}
#$dbhistory += $Log
$dbhistory += $DatabaseHistory | Where-Object {$_.BackupSetID -eq $Group.group[0].BackupSetID}
$Log = $Group.group[0]
$Log.FullName = $Group.group.fullname
$dbhistory += $Log
}
# Get Last T-log
$dbHistory += $DatabaseHistory | Where-Object {$_.Type -in ('Log', 'Transaction Log') -and $_.End -ge $RestoreTime -and $_.DatabaseBackupLSN -eq $Full.CheckpointLSN} | Sort-Object -Property LastLsn, FirstLsn | Select-Object -First 1

$lastLog = $DatabaseHistory | Where-Object {$_.Type -in ('Log', 'Transaction Log') -and $_.End -ge $RestoreTime -and $_.DatabaseBackupLSN -eq $Full.CheckpointLSN} | Sort-Object -Property LastLsn, FirstLsn | Select-Object -First 1
if ($null -ne $lastlog) {
$lastLog.FullName = ($DatabaseHistory | Where-Object { $_.BackupSetID -eq $lastLog.BackupSetID }).Fullname
}
$dbHistory += $lastLog
}
$dbhistory
}
[int]$BackupPriority,
[ValidateSet('AllowAllConnections', 'AllowReadWriteConnections')]
[string]$ConnectionModeInPrimaryRole,
[ValidateSet('AllowAllConnections', 'AllowNoConnections', 'AllowReadIntentConnectionsOnly')]
[ValidateSet('AllowAllConnections', 'AllowNoConnections', 'AllowReadIntentConnectionsOnly', 'No', 'Read-intent only', 'Yes')]
[string]$ConnectionModeInSecondaryRole,
[ValidateSet('Automatic', 'Manual')]
[string]$SeedingMode,
}
}

if ($ConnectionModeInSecondaryRole) {
$ConnectionModeInSecondaryRole =
switch ($ConnectionModeInSecondaryRole) {
"No" { "AllowNoConnections" }
"Read-intent only" { "AllowReadIntentConnectionsOnly" }
"Yes" { "AllowAllConnections" }
default { $ConnectionModeInSecondaryRole }
}
}

if ($SqlInstance) {
$InputObject += Get-DbaAgReplica -SqlInstance $SqlInstance -SqlCredential $SqlCredential -AvailabilityGroup $AvailabilityGroup -Replica $Replica
}
"false",
""
],
[
"IncludeMirror",
"By default mirrors of backups are not returned, this switch will cause them to be returned",
"",
false,
"false",
"False"
],
[
"Type",
"Specifies one or more types of backups to return. Valid options are \u0027Full\u0027, \u0027Log\u0027, \u0027Differential\u0027, \u0027File\u0027, \u0027Differential File\u0027, \u0027Partial Full\u0027, and \u0027Partial Differential\u0027. Otherwise, all types of \r\nbackups will be returned unless one of the -Last* switches is enabled.",
"False"
]
],
"Syntax": "Get-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Force] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-Last] [-LastFull] [-LastDiff] [-LastLog] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]"
"Syntax": "Get-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-IncludeMirror] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Force] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-IncludeMirror] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-Last] [-LastFull] [-LastDiff] [-LastLog] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-IncludeMirror] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]"
},
{
"Name": "Get-DbaBackupInformation",
@@ -1,7 +1,7 @@

-- SQL Server 2012 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: March 29, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -134,9 +134,6 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- Performance Related Fixes in Post-SQL Server 2012 RTM Builds
-- https://bit.ly/2vuIQn4

-- Announcing updates to the SQL Server Incremental Servicing Model (ISM)
-- https://bit.ly/1RzYITz

-- Update Center for Microsoft SQL Server
-- https://bit.ly/2pZptuQ

@@ -1,7 +1,7 @@

-- SQL Server 2014 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: March 22, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -119,9 +119,6 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- Performance and Stability Related Fixes in Post-SQL Server 2014 SP3 Builds
-- https://bit.ly/2PRGTWS

-- Announcing updates to the SQL Server Incremental Servicing Model (ISM)
-- https://bit.ly/1RzYITz

-- Update Center for Microsoft SQL Server
-- https://bit.ly/2pZptuQ

@@ -1,7 +1,7 @@

-- SQL Server 2016 SP2 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: March 22, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -93,9 +93,6 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- Performance and Stability Related Fixes in Post-SQL Server 2016 SP2 Builds
-- https://bit.ly/2K3LoPf

-- Announcing updates to the SQL Server Incremental Servicing Model (ISM)
-- https://bit.ly/1RzYITz

-- Update Center for Microsoft SQL Server
-- https://bit.ly/2pZptuQ

@@ -1,7 +1,7 @@

-- SQL Server 2016 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: March 22, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -109,9 +109,6 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- Performance and Stability Related Fixes in Post-SQL Server 2016 SP2 Builds
-- https://bit.ly/2K3LoPf

-- Announcing updates to the SQL Server Incremental Servicing Model (ISM)
-- https://bit.ly/1RzYITz

-- Update Center for Microsoft SQL Server
-- https://bit.ly/2pZptuQ

@@ -1,7 +1,7 @@

-- SQL Server 2017 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: March 25, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -105,7 +105,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- https://bit.ly/2saQ4Yh

-- Announcing the Modern Servicing Model for SQL Server
-- https://bit.ly/2xHnh0l
-- https://bit.ly/2KtJ8SS

-- SQL Server Service Packs are discontinued starting from SQL Server 2017
-- https://bit.ly/2GTkbgt
@@ -1,7 +1,7 @@

-- SQL Server 2019 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: March 28, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -77,7 +77,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
-- https://bit.ly/2PY442b

-- Announcing the Modern Servicing Model for SQL Server
-- https://bit.ly/2xHnh0l
-- https://bit.ly/2KtJ8SS

-- SQL Server Service Packs are discontinued starting from SQL Server 2017
-- https://bit.ly/2GTkbgt
@@ -1,7 +1,7 @@

-- Azure SQL Database Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: February 1, 2019
-- Last Modified: April 11, 2019
-- https://www.sqlskills.com/blogs/glenn/
-- http://sqlserverperformance.wordpress.com/
-- Twitter: GlennAlanBerry
@@ -11,7 +11,7 @@
RootModule = 'dbatools.psm1'

# Version number of this module.
ModuleVersion = '0.9.803'
ModuleVersion = '0.9.804'

# ID used to uniquely identify this module
GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'

0 comments on commit 3184e2d

Please sign in to comment.
You can’t perform that action at this time.