Skip to content

Commit 17e10f3

Browse files
authored
Remove Undefined from StateChange enum (#461)
1 parent 743c918 commit 17e10f3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- `azure-pipelines.yml`
1111
- Remove `windows-2019` images fixes [#451](https://github.com/dsccommunity/ComputerManagementDsc/issues/451).
1212
- Module manifest: Set `CmdletsToExport` to `'*'` to satisfy HQRM tests.
13+
- ScheduledTask
14+
- Removed Undefined from ScheduledTask enum
15+
Fixes [Issue #460](https://github.com/dsccommunity/ComputerManagementDsc/issues/460).
1316

1417
### Fixed
1518

source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace ScheduledTask
1313
}
1414
public enum StateChange : uint
1515
{
16-
Undefined = 0,
1716
OnConnectionFromLocalComputer = 1,
1817
OnDisconnectFromLocalComputer = 2,
1918
OnConnectionFromRemoteComputer = 3,
@@ -2127,7 +2126,14 @@ function Get-CurrentResource
21272126
EventSubscription = $trigger.Subscription
21282127
EventValueQueries = ConvertTo-HashtableFromTaskNamedValuePairCollection -Array $trigger.ValueQueries
21292128
Delay = ConvertTo-TimeSpanStringFromScheduledTaskString -TimeSpan $trigger.Delay
2130-
StateChange = [System.String][ScheduledTask.StateChange][System.UInt32] $trigger.StateChange # Cast to integer first to allow casting to enum with null
2129+
}
2130+
2131+
if ($trigger.StateChange)
2132+
{
2133+
$result.Add('StateChange', [System.String][ScheduledTask.StateChange][System.UInt32] $trigger.StateChange)
2134+
}
2135+
else {
2136+
$result.Add('StateChange', $null)
21312137
}
21322138

21332139
if (

0 commit comments

Comments
 (0)