Fix boolean logic and inline docs #6874
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Purpose
Fix some boolean logic and the cmdlet name in the inline documentation
Approach
Line 119, as originally written,
if (-not $InputObject -and (-not $Schedule -or $ScheduleUid)) {
would only allow you to get past this point if you have either $InputObject or have $Schedule and not have $ScheduleUid, which makes no sense and contradicts the error message.
I believe the
-not
should have been outside the parentheses, as inif (-not $InputObject -and -not ($Schedule -or $ScheduleUid)) {
but it seems more clear to use the logical equivalent
if (-not ($InputObject -or $Schedule -or $ScheduleUid)) {
to say "If you don't have at least one of these, you may not continue"
Commands to test
Neither of these should return the error "Please enter the schedule or schedule uid"
Remove-DbaAgentSchedule -SqlInstance sql1 -ScheduleUid 'bf57fa7e-7720-4936-85a0-87d279db7eb7'
Remove-DbaAgentSchedule -SqlInstance sql1 -Schedule 'schedule1'