Skip to content

Commit 88277cb

Browse files
authored
Merge pull request #150 from PowerShell/dev
Release of version 4.1.0.0 of xComputerManagement
2 parents e67f58e + 4dc1938 commit 88277cb

6 files changed

Lines changed: 152 additions & 67 deletions

File tree

CHANGELOG.md

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

33
## Unreleased
44

5+
## 4.1.0.0
6+
7+
- xScheduledTask:
8+
- Update existing Scheduled Task using SetScheduleTask
9+
instead of UnRegister/Register - See [Issue #134](https://github.com/PowerShell/xComputerManagement/issues/134).
10+
- Fix master branch AppVeyor badge link URL in README.MD - See [Issue #140](https://github.com/PowerShell/xComputerManagement/issues/140).
11+
- Fix deletion of scheduled task with unknown or empty task trigger.
12+
Get-TargetResource returns an empty ScheduleType string if the task
13+
trigger is empty or unknown - See [Issue
14+
#137](https://github.com/PowerShell/xComputerManagement/issues/137).
15+
- Added dependency information for xScheduledTask to README.MD.
16+
517
## 4.0.0.0
618

719
- BREAKING CHANGE: xScheduledTask:

Modules/xComputerManagement/DSCResources/MSFT_xScheduledTask/MSFT_xScheduledTask.psm1

Lines changed: 37 additions & 17 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

@@ -1128,10 +1127,7 @@ function Set-TargetResource
11281127
}
11291128

11301129
# Prepare the register arguments
1131-
$registerArguments = @{
1132-
TaskName = $TaskName
1133-
TaskPath = $TaskPath
1134-
}
1130+
$registerArguments = @{}
11351131

11361132
if ($PSBoundParameters.ContainsKey('ExecuteAsCredential'))
11371133
{
@@ -1179,18 +1175,29 @@ function Set-TargetResource
11791175
Principal = $principal
11801176
}
11811177

1178+
$tempScheduledTask = New-ScheduledTask @scheduledTaskArguments -ErrorAction Stop
1179+
11821180
if ($currentValues.Ensure -eq 'Present')
11831181
{
1184-
Write-Verbose -Message ($script:localizedData.RemovePreviousScheduledTaskMessage -f $TaskName, $TaskPath)
1185-
1186-
$null = Unregister-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -Confirm:$false -ErrorAction Stop
1182+
Write-Verbose -Message ($script:localizedData.RetrieveScheduledTaskMessage -f $TaskName, $TaskPath)
1183+
$tempScheduledTask = New-ScheduledTask @scheduledTaskArguments -ErrorAction Stop
1184+
1185+
$scheduledTask = Get-ScheduledTask `
1186+
-TaskName $currentValues.TaskName `
1187+
-TaskPath $currentValues.TaskPath `
1188+
-ErrorAction Stop
1189+
$scheduledTask.Actions = $action
1190+
$scheduledTask.Triggers = $tempScheduledTask.Triggers
1191+
$scheduledTask.Settings = $setting
1192+
$scheduledTask.Principal = $principal
1193+
}
1194+
else
1195+
{
1196+
$scheduledTask = $tempScheduledTask
11871197
}
11881198

11891199
Write-Verbose -Message ($script:localizedData.CreateNewScheduledTaskMessage -f $TaskName, $TaskPath)
11901200

1191-
# Create the scheduled task object
1192-
$scheduledTask = New-ScheduledTask @scheduledTaskArguments -ErrorAction Stop
1193-
11941201
if ($repetition)
11951202
{
11961203
Write-Verbose -Message ($script:localizedData.SetRepetitionTriggerMessage -f $TaskName, $TaskPath)
@@ -1203,12 +1210,25 @@ function Set-TargetResource
12031210
$scheduledTask.Description = $Description
12041211
}
12051212

1206-
# Register the scheduled task
1207-
$registerArguments.Add('InputObject', $scheduledTask)
1213+
if ($currentValues.Ensure -eq 'Present')
1214+
{
1215+
# Updating the scheduled task
12081216

1209-
Write-Verbose -Message ($script:localizedData.RegisterScheduledTaskMessage -f $TaskName, $TaskPath)
1217+
Write-Verbose -Message ($script:localizedData.UpdateScheduledTaskMessage -f $TaskName, $TaskPath)
1218+
$null = Set-ScheduledTask -InputObject $scheduledTask @registerArguments
1219+
}
1220+
else
1221+
{
1222+
Write-Verbose -Message ($script:localizedData.CreateNewScheduledTaskMessage -f $TaskName, $TaskPath)
1223+
1224+
# Register the scheduled task
12101225

1211-
$null = Register-ScheduledTask @registerArguments -ErrorAction Stop
1226+
$registerArguments.Add('TaskName',$TaskName)
1227+
$registerArguments.Add('TaskPath',$TaskPath)
1228+
$registerArguments.Add('InputObject', $scheduledTask)
1229+
1230+
$null = Register-ScheduledTask @registerArguments
1231+
}
12121232
}
12131233

12141234
if ($Ensure -eq 'Absent')

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

Lines changed: 3 additions & 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}'.
@@ -22,7 +22,9 @@ ConvertFrom-StringData @'
2222
CreateNewScheduledTaskMessage = Creating new scheduled task '{0}' in '{1}'.
2323
SetRepetitionTriggerMessage = Setting repetition trigger settings on task '{0}' in '{1}'.
2424
RegisterScheduledTaskMessage = Registering the scheduled task '{0}' in '{1}'.
25+
RetrieveScheduledTaskMessage = Retrieving the scheduled task '{0}' from '{1}'.
2526
RemoveScheduledTaskMessage = Removing scheduled task '{0}' from '{1}'.
27+
UpdateScheduledTaskMessage = Updating scheduled task '{0}' in '{1}'.
2628
TestScheduledTaskMessage = Testing scheduled task '{0}' in '{1}'.
2729
GetCurrentTaskValuesMessage = Current scheduled task values retrieved.
2830
CurrentTaskValuesNullMessage = Current scheduled values were null.

Modules/xComputerManagement/xComputerManagement.psd1

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
# Version number of this module.
3-
ModuleVersion = '4.0.0.0'
3+
moduleVersion = '4.1.0.0'
44

55
# ID used to uniquely identify this module
66
GUID = 'B5004952-489E-43EA-999C-F16A25355B89'
@@ -49,22 +49,15 @@ PrivateData = @{
4949
# IconUri = ''
5050

5151
# ReleaseNotes of this module
52-
ReleaseNotes = '- BREAKING CHANGE: xScheduledTask:
53-
- Breaking change because `Get-TargetResource` no longer outputs
54-
`ActionExecutable` and `ScheduleType` properties when the scheduled
55-
task does not exist. It will also include `TaskPath` in output when
56-
scheduled task does not exist.
57-
- xScheduledTask:
58-
- Add support to disable built-in scheduled tasks - See [Issue 74](https://github.com/PowerShell/xComputerManagement/issues/74).
59-
- Fix unit test mocked schedule task object structure.
60-
- Fix error message when trigger type is unknown - See [Issue 121](https://github.com/PowerShell/xComputerManagement/issues/121).
61-
- Moved strings into separate strings file.
62-
- Updated to meet HQRM guidelines.
63-
- xComputer:
64-
- Resolved bug in Get-ComputerDomain where LocalSystem doesn"t have
65-
rights to the domain.
66-
- Updated tests to meet Pester V4 guidelines - See [Issue 106](https://github.com/PowerShell/xComputerManagement/issues/106).
67-
- Converted module to use auto documentation format.
52+
ReleaseNotes = '- xScheduledTask:
53+
- Update existing Scheduled Task using SetScheduleTask
54+
instead of UnRegister/Register - See [Issue 134](https://github.com/PowerShell/xComputerManagement/issues/134).
55+
- Fix master branch AppVeyor badge link URL in README.MD - See [Issue 140](https://github.com/PowerShell/xComputerManagement/issues/140).
56+
- Fix deletion of scheduled task with unknown or empty task trigger.
57+
Get-TargetResource returns an empty ScheduleType string if the task
58+
trigger is empty or unknown - See [Issue
59+
137](https://github.com/PowerShell/xComputerManagement/issues/137).
60+
- Added dependency information for xScheduledTask to README.MD.
6861
6962
'
7063

@@ -82,3 +75,4 @@ PrivateData = @{
8275

8376

8477

78+

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ The **xComputerManagement** module contains the following resources:
1111
- **xScheduledTask**: is used to define basic run once or recurring scheduled tasks
1212
on the local computer. It can also be used to delete or disable built-in
1313
scheduled tasks.
14+
15+
_The **xScheduledTask** resource requires the `ScheduledTasks` PowerShell module
16+
which is only available on Windows Server 2012/Windows 8 and above. DSC configurations
17+
containing this resource may be compiled on Windows Server 2008 R2/Windows 7 but
18+
can not be applied._
1419
- **xVirtualMemory**: allows configuration of properties of the paging file on
1520
the local computer.
1621

@@ -28,7 +33,7 @@ out the [xComputerManagement wiki](https://github.com/PowerShell/xComputerManage
2833

2934
### master
3035

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

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

0 commit comments

Comments
 (0)