mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add -Force to Remove-CronJob
This commit is contained in:
1 parent
d7d516a066
commit
444769cb6b
1 file changed
+7
-2
@@ -85,6 +85,8 @@ function Remove-CronJob {
|
||||
Optional parameter to specify a specific user's cron table
|
||||
.PARAMETER Job
|
||||
Cron job object returned from Get-CronJob
|
||||
.PARAMETER Force
|
||||
Don't prompt when removing the cron job
|
||||
#>
|
||||
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact="High")]
|
||||
param (
|
||||
@@ -97,7 +99,10 @@ function Remove-CronJob {
|
||||
[Alias("j")]
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
|
||||
[CronJob]
|
||||
$Job
|
||||
$Job,
|
||||
|
||||
[Switch]
|
||||
$Force
|
||||
)
|
||||
process {
|
||||
|
||||
@@ -118,7 +123,7 @@ function Remove-CronJob {
|
||||
$e = New-Object System.Exception -ArgumentList "Job not found"
|
||||
throw $e
|
||||
}
|
||||
if ($pscmdlet.ShouldProcess($Job.Command,"Remove")) {
|
||||
if ($Force -or $pscmdlet.ShouldProcess($Job.Command,"Remove")) {
|
||||
Import-CronTab -user $UserName -crontab $newcrontab
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user