mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Fix Remove-CronTab to only remove the correct job(s)
This commit is contained in:
1 parent
3dafae5357
commit
af27a06f89
1 file changed
+8
-2
@@ -11,6 +11,12 @@ class CronJob {
|
||||
[string] $Month
|
||||
[string] $DayOfWeek
|
||||
[string] $Command
|
||||
|
||||
[string] ToString()
|
||||
{
|
||||
return "{0} {1} {2} {3} {4} {5}" -f
|
||||
$this.Minute, $this.Hour, $this.DayOfMonth, $this.Month, $this.DayOfWeek, $this.Command
|
||||
}
|
||||
}
|
||||
|
||||
# Internal helper functions
|
||||
@@ -100,9 +106,9 @@ function Remove-CronJob {
|
||||
$newcrontab = [List[string]]::new()
|
||||
$found = $false
|
||||
|
||||
$JobAsString = $Job.ToString()
|
||||
foreach ($line in $crontab) {
|
||||
$cronjob = ConvertTo-CronJob -crontab $line
|
||||
if ((Compare-object $cronjob.psobject.properties $Job.psobject.properties) -eq $null) {
|
||||
if ($JobAsString -ceq $line) {
|
||||
$found = $true
|
||||
} else {
|
||||
$newcrontab.Add($line)
|
||||
|
||||
Reference in new issue
Block a user