Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Set-DbaAgentJobStep] - Added ShouldProcess to the Rename to fix #8140 #8141

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions functions/Set-DbaAgentJobStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ function Set-DbaAgentJobStep {
#region job step options
# Setting the options for the job step
if ($NewName) {
Write-Message -Message "Setting job step name to $NewName" -Level Verbose
$jobStep.Rename($NewName)
if ($Pscmdlet.ShouldProcess($server, "Setting job step name to $NewName for $StepName")) {
$jobStep.Rename($NewName)
}
}

if ($Subsystem) {
Expand Down Expand Up @@ -372,9 +373,9 @@ function Set-DbaAgentJobStep {
#region job step options

# Execute
if ($PSCmdlet.ShouldProcess($server, "Changing the job step '$StepName' for job '$j'")) {
if ($PSCmdlet.ShouldProcess($server, "Committing changes for job step '$StepName' for job '$j'")) {
try {
Write-Message -Message "Changing the job step '$StepName' for job '$j' on $server" -Level Verbose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verbose message not needed, as ShouldProcess always writes verbose output.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's true! I didnt realize this until years later. I'm going to merge nevertheless, since this is an important change

Write-Message -Message "Committing changes for '$StepName' for job '$j' on $server" -Level Verbose

# Change the job step
$jobStep.Alter()
Expand Down