Skip to content

Copy-DbaAgentJob - Add -NewName parameter to allow copying jobs to sa…#10371

Open
frodr1k wants to merge 1 commit into
dataplat:developmentfrom
frodr1k:Copy-dbnaagentjob-update
Open

Copy-DbaAgentJob - Add -NewName parameter to allow copying jobs to sa…#10371
frodr1k wants to merge 1 commit into
dataplat:developmentfrom
frodr1k:Copy-dbnaagentjob-update

Conversation

@frodr1k
Copy link
Copy Markdown

@frodr1k frodr1k commented May 18, 2026

…me server

Adds a -NewName parameter that allows copying a job under a different name. When source and destination are the same server, -NewName is required. Cannot be used when copying multiple jobs simultaneously.

(do Copy-DbaAgentJob)

Summary
Added -NewName parameter to Copy-DbaAgentJob to allow copying a job under a different name, including to the same server.

Why
It was not possible to copy a job to the same server instance since all jobs on a server must have unique names. Users needed a way to create job copies/variants — similar to how -NewName already works in Copy-DbaDatabase. For example Ole Hallengrens Backup-command allows a parameter named "DatabasesInParallel" which needs the backupjobs to be identical. Hence this avoids typos.

Changes
Added -NewName parameter that sets the destination job name
Copying to same server now requires -NewName (fails with clear error otherwise)
-NewName cannot be used when copying multiple jobs simultaneously
Updated parameter validation test and added 3 integration tests
Testing
Verified manually against SQL Server instance. Integration tests added for same-server copy, cross-server rename, and error case without -NewName.

Closes #10370

…me server

Adds a -NewName parameter that allows copying a job under a different name.
When source and destination are the same server, -NewName is required.
Cannot be used when copying multiple jobs simultaneously.

(do Copy-DbaAgentJob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

copy-dbaagentjob do not allow copy to same server.

1 participant