Skip to content

Commit 4e81cec

Browse files
Thomas CalvoThomas Calvo
authored andcommitted
Merge branch 'dev' of https://github.com/PowerShell/xComputerManagement into setupdate
2 parents 7a88ad1 + af8d9eb commit 4e81cec

5 files changed

Lines changed: 56 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
- Fix master branch AppVeyor badge link URL in README.MD - See [Issue #140](https://github.com/PowerShell/xComputerManagement/issues/140).
6+
- Fix deletion of scheduled task with unknown or empty task trigger.
7+
Get-TargetResource returns an empty ScheduleType string if the task
8+
trigger is empty or unknown - See [Issue
9+
#137](https://github.com/PowerShell/xComputerManagement/issues/137).
10+
511
## 4.0.0.0
612

713
- BREAKING CHANGE: xScheduledTask:

Modules/xComputerManagement/DSCResources/MSFT_xScheduledTask/MSFT_xScheduledTask.psm1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,8 @@ function Get-TargetResource
438438

439439
default
440440
{
441-
New-InvalidArgumentException `
442-
-Message ($script:localizedData.TriggerTypeError -f $trigger.CimClass.CimClassName) `
443-
-ArgumentName CimClassName
441+
$returnScheduleType = ''
442+
Write-Verbose -Message ($script:localizedData.TriggerTypeUnknown -f $trigger.CimClass.CimClassName)
444443
}
445444
}
446445

Modules/xComputerManagement/DSCResources/MSFT_xScheduledTask/en-US/MSFT_xScheduledTask.strings.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ConvertFrom-StringData @'
22
GetScheduledTaskMessage = Getting scheduled task '{0}' in '{1}'.
33
TaskNotFoundMessage = Task '{0}' not found in '{1}'. Returning an empty task with Ensure = "Absent".
44
TaskFoundMessage = Task '{0}' found in '{1}'. Retrieving settings, first action, first trigger and repetition settings.
5-
TriggerTypeError = Trigger type '{0}' not recognized.
5+
TriggerTypeUnknown = Trigger type '{0}' not recognized.
66
DetectedScheduleTypeMessage = Detected schedule type '{0}' for first trigger.
77
SetScheduledTaskMessage = Setting scheduled task '{0}' in '{1}'.
88
DisablingExistingScheduledTask = Disabling existing scheduled task '{0}' in '{1}'.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ out the [xComputerManagement wiki](https://github.com/PowerShell/xComputerManage
2828

2929
### master
3030

31-
[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xsqlserver/branch/master)
31+
[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xComputerManagement/branch/master)
3232
[![codecov](https://codecov.io/gh/PowerShell/xComputerManagement/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/xComputerManagement/branch/master)
3333

3434
This is the branch containing the latest release - no contributions should be made

Tests/Unit/MSFT_xScheduledTask.Tests.ps1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,52 @@ try
15001500
Test-TargetResource @testParameters | Should -Be $true
15011501
}
15021502
}
1503+
1504+
Context 'When a built-in scheduled task exists and is enabled, but it should be disabled and the trigger type is not recognized' {
1505+
$testParameters = @{
1506+
TaskName = 'Test task'
1507+
TaskPath = '\Test\'
1508+
Enable = $false
1509+
Verbose = $True
1510+
}
1511+
1512+
Mock -CommandName Get-ScheduledTask -MockWith {
1513+
@{
1514+
TaskName = $testParameters.TaskName
1515+
TaskPath = $testParameters.TaskPath
1516+
Actions = [pscustomobject] @{
1517+
Execute = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
1518+
}
1519+
Triggers = [pscustomobject] @{
1520+
Repetition = @{
1521+
Duration = "PT15M"
1522+
Interval = "PT15M"
1523+
}
1524+
CimClass = @{
1525+
CimClassName = 'MSFT_TaskEventTrigger'
1526+
}
1527+
}
1528+
Settings = [pscustomobject] @{
1529+
Enabled = $true
1530+
}
1531+
} }
1532+
1533+
It 'Should return the correct values from Get-TargetResource' {
1534+
$result = Get-TargetResource @testParameters
1535+
$result.Enable | Should -Be $true
1536+
$result.Ensure | Should -Be 'Present'
1537+
$result.ScheduleType | Should -BeNullOrEmpty
1538+
}
1539+
1540+
It 'Should return false from the test method' {
1541+
Test-TargetResource @testParameters | Should -Be $false
1542+
}
1543+
1544+
It 'Should disable the scheduled task in the set method' {
1545+
Set-TargetResource @testParameters
1546+
Assert-MockCalled Register-ScheduledTask -Exactly -Times 1
1547+
}
1548+
}
15031549
}
15041550
}
15051551
#endregion

0 commit comments

Comments
 (0)