Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
46cbf45
Copy-DbaAgentJob - Stop writing a $null into the output of every copi…
andreasjordan Oct 17, 2026
55a8b4a
Copy-DbaAgentJobCategory - Stop writing a $null into the output of ev…
andreasjordan Oct 17, 2026
24c941f
Copy-DbaAgentJobStep - Stop writing a $null into the output for every…
andreasjordan Oct 17, 2026
eab9cdf
Copy-DbaAgentOperator - Stop writing a $null into the output of every…
andreasjordan Oct 17, 2026
03f1132
Copy-DbaAgentProxy - Stop writing a $null into the output of every co…
andreasjordan Oct 17, 2026
03540e3
Copy-DbaAgentSchedule - Stop writing a $null into the output of every…
andreasjordan Oct 17, 2026
592830d
Copy-DbaBackupDevice - Stop writing a $null into the output of every …
andreasjordan Oct 17, 2026
1eaecd8
Copy-DbaCustomError - Stop writing a $null into the output of every c…
andreasjordan Oct 17, 2026
8fa4d8c
Copy-DbaDataCollector - Stop writing a $null into the output of every…
andreasjordan Oct 17, 2026
204c4c0
Copy-DbaDbAssembly - Stop writing a $null into the output of every co…
andreasjordan Oct 17, 2026
b66bf80
Copy-DbaInstanceAudit - Output skipped audits, drop their specificati…
andreasjordan Oct 17, 2026
649e45a
Copy-DbaInstanceAuditSpecification - Stop writing a $null into the ou…
andreasjordan Oct 17, 2026
e0d7d0f
Copy-DbaLinkedServer - Stop writing a $null into the output for linke…
andreasjordan Oct 17, 2026
7f80f41
Copy-DbaResourceGovernor - Copy pools with -ExcludeResourcePool and -…
andreasjordan Oct 17, 2026
c69c4ae
Copy-DbaServerRole - Stop writing a $null into the output of every co…
andreasjordan Oct 17, 2026
9b3b84c
Copy-DbaStartupProcedure - Stop writing a $null into the output with …
andreasjordan Oct 17, 2026
32a9d40
Copy-DbaSystemDbUserObject - Stop writing a $null for every statement…
andreasjordan Oct 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/Copy-DbaAgentJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ WHERE j.job_id = @jobId"
}

Write-Message -Message $sql -Level Debug
$destServer.Query($sql)
$null = $destServer.Query($sql)

$destServer.JobServer.Jobs.Refresh()
$destServer.JobServer.Jobs[$destJobName].IsEnabled = $sourceServer.JobServer.Jobs[$serverJob.name].IsEnabled
Expand Down
10 changes: 5 additions & 5 deletions public/Copy-DbaAgentJobCategory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function Copy-DbaAgentJobCategory {
Write-Message -Level Verbose -Message "Copying Job category $categoryName"
$sql = $jobCategory.Script() | Out-String
Write-Message -Level Debug -Message "SQL Statement: $sql"
$destServer.Query($sql)
$null = $destServer.Query($sql)
$copyJobCategoryStatus.Status = "Successful"
$copyJobCategoryStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
} catch {
Expand Down Expand Up @@ -255,7 +255,7 @@ function Copy-DbaAgentJobCategory {
Write-Message -Level Verbose -Message "Copying Operator category $categoryName"
$sql = $operatorCategory.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)
} catch {
$copyOperatorCategoryStatus.Status = "Failed"
$copyOperatorCategoryStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Expand All @@ -270,7 +270,7 @@ function Copy-DbaAgentJobCategory {
Write-Message -Level Verbose -Message "Copying Operator category $categoryName"
$sql = $operatorCategory.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)

$copyOperatorCategoryStatus.Status = "Successful"
$copyOperatorCategoryStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Expand Down Expand Up @@ -343,7 +343,7 @@ function Copy-DbaAgentJobCategory {
Write-Message -Level Verbose -Message "Copying Alert category $categoryName"
$sql = $alertcategory.Script() | Out-String
Write-Message -Level Debug -Message "SQL Statement: $sql"
$destServer.Query($sql)
$null = $destServer.Query($sql)
} catch {
$copyAlertCategoryStatus.Status = "Failed"
$copyAlertCategoryStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Expand All @@ -358,7 +358,7 @@ function Copy-DbaAgentJobCategory {
Write-Message -Level Verbose -Message "Copying Alert category $categoryName"
$sql = $alertCategory.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)

$copyAlertCategoryStatus.Status = "Successful"
$copyAlertCategoryStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaAgentJobStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function Copy-DbaAgentJobStep {
# Replace @job_id with @job_name since the destination job has a different GUID
$sql = $sql -replace "@job_id=N'[0-9a-fA-F-]+'", "@job_name=N'$($jobName -replace "'", "''")'"
Write-Message -Message $sql -Level Debug
$destServer.Query($sql)
$null = $destServer.Query($sql)
}

$destJob.JobSteps.Refresh()
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaAgentOperator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function Copy-DbaAgentOperator {
Write-Message -Level Verbose -Message "Copying Operator $operatorName"
$sql = $sOperator.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)
$destServer.JobServer.Operators.Refresh()

$copyOperatorStatus.Status = "Successful"
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaAgentProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function Copy-DbaAgentProxy {
Write-Message -Level Verbose -Message "Copying server proxy account $proxyName"
$sql = $account.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)

# Will fixing this misspelled status cause problems downstream?
$copyAgentProxyAccountStatus.Status = "Successful"
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaAgentSchedule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function Copy-DbaAgentSchedule {
$sql = $currentschedule.Script() | Out-String

Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)

$copySharedScheduleStatus.Status = "Successful"
$copySharedScheduleStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaBackupDevice.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function Copy-DbaBackupDevice {
if ($Pscmdlet.ShouldProcess($destinstance, "Adding backup device $deviceName")) {
Write-Message -Level Verbose -Message "Adding backup device $deviceName on $destinstance"
try {
$destServer.Query($sql)
$null = $destServer.Query($sql)
$destServer.BackupDevices.Refresh()

$copyBackupDeviceStatus.Status = "Successful"
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaCustomError.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function Copy-DbaCustomError {
Write-Message -Level Verbose -Message "Copying custom error $customErrorId $language"
$sql = $currentCustomError.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)
$copyCustomErrorStatus.Status = "Successful"
$copyCustomErrorStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
} catch {
Expand Down
4 changes: 2 additions & 2 deletions public/Copy-DbaDataCollector.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function Copy-DbaDataCollector {
if ($Pscmdlet.ShouldProcess($destinstance, "Attempting to modify Data Collector configuration")) {
try {
$sql = "Unknown at this time"
$destServer.Query($sql)
$null = $destServer.Query($sql)
$destStore.Alter()
} catch {
$copyServerConfigStatus.Status = "Failed"
Expand Down Expand Up @@ -243,7 +243,7 @@ function Copy-DbaDataCollector {
$sql = $sql -replace [Regex]::Escape("'$source'"), "'$destinstance'"
Write-Message -Level Debug -Message $sql
Write-Message -Level Verbose -Message "Migrating collection set $collectionName"
$destServer.Query($sql)
$null = $destServer.Query($sql)
$copyCollectionSetStatus.Status = "Successful"
$copyCollectionSetStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
} catch {
Expand Down
6 changes: 3 additions & 3 deletions public/Copy-DbaDbAssembly.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function Copy-DbaDbAssembly {
$sql = "ALTER DATABASE $dbName SET TRUSTWORTHY ON"
try {
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)
} catch {
$copyDbAssemblyStatus.Status = "Failed to set security level to external"
$copyDbAssemblyStatus.Notes = "$PSItem"
Expand Down Expand Up @@ -231,7 +231,7 @@ function Copy-DbaDbAssembly {
throw "$assemblyName has dependencies but this command does not yet support dependent objects"
}

$destDb.Query("DROP ASSEMBLY $assemblyName")
$null = $destDb.Query("DROP ASSEMBLY $assemblyName")
} catch {
$copyDbAssemblyStatus.Status = "Failed"
$copyDbAssemblyStatus.Notes = "$PSItem"
Expand All @@ -248,7 +248,7 @@ function Copy-DbaDbAssembly {
Write-Message -Level Verbose -Message "Copying assembly $assemblyName from database."
$sql = $currentAssembly.Script()
Write-Message -Level Debug -Message ($sql -join ' ')
$destDb.Query($sql, $dbName)
$null = $destDb.Query($sql)

$copyDbAssemblyStatus.Status = "Successful"
$copyDbAssemblyStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Expand Down
13 changes: 8 additions & 5 deletions public/Copy-DbaInstanceAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,20 @@ function Copy-DbaInstanceAudit {
if ($Pscmdlet.ShouldProcess($destinstance, "Server audit $auditName exists at destination. Use -Force to drop and migrate.")) {
$copyAuditStatus.Status = "Skipped"
$copyAuditStatus.Notes = "Already exists on destination"
$copyAuditStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Write-Message -Level Verbose -Message "Server audit $auditName exists at destination. Use -Force to drop and migrate."
}
continue
} else {
if ($Pscmdlet.ShouldProcess($destinstance, "Dropping server audit $auditName")) {
try {
Write-Message -Level Verbose -Message "Dropping server audit $auditName."
foreach ($spec in $destServer.ServerAuditSpecifications) {
if ($auditSpecification.Auditname -eq $auditName) {
$auditSpecification.Drop()
}
# Collected first, a drop inside the enumeration would modify the collection
$destAuditSpecs = @($destServer.ServerAuditSpecifications | Where-Object AuditName -eq $auditName)
foreach ($spec in $destAuditSpecs) {
Write-Message -Level Verbose -Message "Dropping server audit specification $($spec.Name) that uses $auditName."
$spec.Disable()
$spec.Drop()
}

$destServer.audits[$auditName].Disable()
Expand Down Expand Up @@ -231,7 +234,7 @@ function Copy-DbaInstanceAudit {
Write-Message -Level Verbose -Message "File path $($currentAudit.Filepath) exists on $destinstance."
Write-Message -Level Verbose -Message "Copying server audit $auditName."
$sql = $currentAudit.Script() | Out-String
$destServer.Query($sql)
$null = $destServer.Query($sql)
$copyAuditStatus.Status = "Successful"
$copyAuditStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
} catch {
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaInstanceAuditSpecification.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function Copy-DbaInstanceAuditSpecification {
Write-Message -Level Verbose -Message "Copying server audit $auditSpecName"
$sql = $auditSpec.Script() | Out-String
Write-Message -Level Debug -Message $sql
$destServer.Query($sql)
$null = $destServer.Query($sql)
$copyAuditSpecStatus.Status = "Successful"
$copyAuditSpecStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
} catch {
Expand Down
2 changes: 1 addition & 1 deletion public/Copy-DbaLinkedServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function Copy-DbaLinkedServer {

if ($copyLinkedServer.ProductName -eq 'SQL Server' -and $copyLinkedServer.Name -ne $copyLinkedServer.DataSource) {
$sql2 = "EXEC sp_setnetname '$($copyLinkedServer.Name)', '$($copyLinkedServer.DataSource)'; "
$destServer.Query($sql2)
$null = $destServer.Query($sql2)
}

$destServer.LinkedServers.Refresh()
Expand Down
Loading
Loading