Summarize Functionality
When a user has their permissions to SQL assigned via AD group membership, and is not directly listed in the SQL Logins table, Copy-DbaAgentJob will skip copying the Agent Job.
Proposal is to include a Switch parameter such as SkipLoginCheck that can be used to override this functionality.
Will likely also need to consider how this impacts the built-in functionality of Copy-DbaAgentServer and Sync-DbaAvailabilityGroup, and whether additional flags will need to be added to those functions when this function is called from those functions.
Is there a command that is similiar or close to what you are looking for?
Yes
Technical Details
Current code that produces the issue:
$missingLogin = $serverJob.OwnerLoginName | Where-Object { $destServer.Logins.Name -notcontains $_ }
if ($missingLogin.Count -gt 0) {
if ($force -eq $false) {
if ($Pscmdlet.ShouldProcess($destinstance, "Login(s) $missingLogin doesn't exist on destination. Use -Force to set owner to [sa]. Skipping job [$jobName].")) {
$missingLogin = ($missingLogin | Sort-Object | Get-Unique) -join ", "
$copyJobStatus.Status = "Skipped"
$copyJobStatus.Notes = "Job is dependent on login $missingLogin"
$copyJobStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Write-Message -Level Verbose -Message "Login(s) $missingLogin doesn't exist on destination. Use -Force to set owner to [sa]. Skipping job [$jobName]."
}
continue
}
}
Proposal is to include a switch parameter, and code would be updated to check the switch parameter:
$missingLogin = $serverJob.OwnerLoginName | Where-Object { $destServer.Logins.Name -notcontains $_ }
if ($missingLogin.Count -gt 0 -and -not $SkipLoginCheck ) {
if ($force -eq $false) {
if ($Pscmdlet.ShouldProcess($destinstance, "Login(s) $missingLogin doesn't exist on destination. Use -Force to set owner to [sa]. Skipping job [$jobName].")) {
$missingLogin = ($missingLogin | Sort-Object | Get-Unique) -join ", "
$copyJobStatus.Status = "Skipped"
$copyJobStatus.Notes = "Job is dependent on login $missingLogin"
$copyJobStatus | Select-DefaultView -Property DateTime, SourceServer, DestinationServer, Name, Type, Status, Notes -TypeName MigrationObject
Write-Message -Level Verbose -Message "Login(s) $missingLogin doesn't exist on destination. Use -Force to set owner to [sa]. Skipping job [$jobName]."
}
continue
}
}
Summarize Functionality
When a user has their permissions to SQL assigned via AD group membership, and is not directly listed in the SQL Logins table, Copy-DbaAgentJob will skip copying the Agent Job.
Proposal is to include a Switch parameter such as SkipLoginCheck that can be used to override this functionality.
Will likely also need to consider how this impacts the built-in functionality of Copy-DbaAgentServer and Sync-DbaAvailabilityGroup, and whether additional flags will need to be added to those functions when this function is called from those functions.
Is there a command that is similiar or close to what you are looking for?
Yes
Technical Details
Current code that produces the issue:
Proposal is to include a switch parameter, and code would be updated to check the switch parameter: