Skip to content

Commit 9f50c6f

Browse files
committed
Moved the parameter check from param section to begin section
1 parent e77bc15 commit 9f50c6f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

functions/Remove-DbaAgentJob.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@ Removes the job from multiple servers using pipe line
7070
[Parameter(Mandatory = $false)]
7171
[int]$JobID,
7272
[Parameter(Mandatory = $false)]
73-
[ValidateScript( {
74-
if (-not($JobID) -and (-not($_))) {
75-
Throw "Please enter a job id or job name."
76-
}
77-
else {
78-
$true
79-
}
80-
})]
8173
[string]$JobName,
8274
[switch]$KeepHistory,
8375
[switch]$KeepUnusedSchedule,
8476
[switch]$Silent
8577
)
8678

79+
begin{
80+
# Check if the job id or jobname are set
81+
if (-not($JobID) -and (-not($JobName))) {
82+
Stop-Function -Message "Please enter a job id or job name." -Target $instance
83+
return
84+
}
85+
}
86+
8787
process {
8888

8989
foreach ($instance in $sqlinstance) {

0 commit comments

Comments
 (0)