Skip to content

Commit

Permalink
Merge pull request #150 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 4.1.0.0 of xComputerManagement
  • Loading branch information
kwirkykat authored Mar 21, 2018
2 parents e67f58e + 4dc1938 commit 88277cb
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 67 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## Unreleased

## 4.1.0.0

- xScheduledTask:
- Update existing Scheduled Task using SetScheduleTask
instead of UnRegister/Register - See [Issue #134](https://github.com/PowerShell/xComputerManagement/issues/134).
- Fix master branch AppVeyor badge link URL in README.MD - See [Issue #140](https://github.com/PowerShell/xComputerManagement/issues/140).
- Fix deletion of scheduled task with unknown or empty task trigger.
Get-TargetResource returns an empty ScheduleType string if the task
trigger is empty or unknown - See [Issue
#137](https://github.com/PowerShell/xComputerManagement/issues/137).
- Added dependency information for xScheduledTask to README.MD.

## 4.0.0.0

- BREAKING CHANGE: xScheduledTask:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,8 @@ function Get-TargetResource

default
{
New-InvalidArgumentException `
-Message ($script:localizedData.TriggerTypeError -f $trigger.CimClass.CimClassName) `
-ArgumentName CimClassName
$returnScheduleType = ''
Write-Verbose -Message ($script:localizedData.TriggerTypeUnknown -f $trigger.CimClass.CimClassName)
}
}

Expand Down Expand Up @@ -1128,10 +1127,7 @@ function Set-TargetResource
}

# Prepare the register arguments
$registerArguments = @{
TaskName = $TaskName
TaskPath = $TaskPath
}
$registerArguments = @{}

if ($PSBoundParameters.ContainsKey('ExecuteAsCredential'))
{
Expand Down Expand Up @@ -1179,18 +1175,29 @@ function Set-TargetResource
Principal = $principal
}

$tempScheduledTask = New-ScheduledTask @scheduledTaskArguments -ErrorAction Stop

if ($currentValues.Ensure -eq 'Present')
{
Write-Verbose -Message ($script:localizedData.RemovePreviousScheduledTaskMessage -f $TaskName, $TaskPath)

$null = Unregister-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -Confirm:$false -ErrorAction Stop
Write-Verbose -Message ($script:localizedData.RetrieveScheduledTaskMessage -f $TaskName, $TaskPath)
$tempScheduledTask = New-ScheduledTask @scheduledTaskArguments -ErrorAction Stop

$scheduledTask = Get-ScheduledTask `
-TaskName $currentValues.TaskName `
-TaskPath $currentValues.TaskPath `
-ErrorAction Stop
$scheduledTask.Actions = $action
$scheduledTask.Triggers = $tempScheduledTask.Triggers
$scheduledTask.Settings = $setting
$scheduledTask.Principal = $principal
}
else
{
$scheduledTask = $tempScheduledTask
}

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

# Create the scheduled task object
$scheduledTask = New-ScheduledTask @scheduledTaskArguments -ErrorAction Stop

if ($repetition)
{
Write-Verbose -Message ($script:localizedData.SetRepetitionTriggerMessage -f $TaskName, $TaskPath)
Expand All @@ -1203,12 +1210,25 @@ function Set-TargetResource
$scheduledTask.Description = $Description
}

# Register the scheduled task
$registerArguments.Add('InputObject', $scheduledTask)
if ($currentValues.Ensure -eq 'Present')
{
# Updating the scheduled task

Write-Verbose -Message ($script:localizedData.RegisterScheduledTaskMessage -f $TaskName, $TaskPath)
Write-Verbose -Message ($script:localizedData.UpdateScheduledTaskMessage -f $TaskName, $TaskPath)
$null = Set-ScheduledTask -InputObject $scheduledTask @registerArguments
}
else
{
Write-Verbose -Message ($script:localizedData.CreateNewScheduledTaskMessage -f $TaskName, $TaskPath)

# Register the scheduled task

$null = Register-ScheduledTask @registerArguments -ErrorAction Stop
$registerArguments.Add('TaskName',$TaskName)
$registerArguments.Add('TaskPath',$TaskPath)
$registerArguments.Add('InputObject', $scheduledTask)

$null = Register-ScheduledTask @registerArguments
}
}

if ($Ensure -eq 'Absent')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ConvertFrom-StringData @'
GetScheduledTaskMessage = Getting scheduled task '{0}' in '{1}'.
TaskNotFoundMessage = Task '{0}' not found in '{1}'. Returning an empty task with Ensure = "Absent".
TaskFoundMessage = Task '{0}' found in '{1}'. Retrieving settings, first action, first trigger and repetition settings.
TriggerTypeError = Trigger type '{0}' not recognized.
TriggerTypeUnknown = Trigger type '{0}' not recognized.
DetectedScheduleTypeMessage = Detected schedule type '{0}' for first trigger.
SetScheduledTaskMessage = Setting scheduled task '{0}' in '{1}'.
DisablingExistingScheduledTask = Disabling existing scheduled task '{0}' in '{1}'.
Expand All @@ -22,7 +22,9 @@ ConvertFrom-StringData @'
CreateNewScheduledTaskMessage = Creating new scheduled task '{0}' in '{1}'.
SetRepetitionTriggerMessage = Setting repetition trigger settings on task '{0}' in '{1}'.
RegisterScheduledTaskMessage = Registering the scheduled task '{0}' in '{1}'.
RetrieveScheduledTaskMessage = Retrieving the scheduled task '{0}' from '{1}'.
RemoveScheduledTaskMessage = Removing scheduled task '{0}' from '{1}'.
UpdateScheduledTaskMessage = Updating scheduled task '{0}' in '{1}'.
TestScheduledTaskMessage = Testing scheduled task '{0}' in '{1}'.
GetCurrentTaskValuesMessage = Current scheduled task values retrieved.
CurrentTaskValuesNullMessage = Current scheduled values were null.
Expand Down
28 changes: 11 additions & 17 deletions Modules/xComputerManagement/xComputerManagement.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
# Version number of this module.
ModuleVersion = '4.0.0.0'
moduleVersion = '4.1.0.0'

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

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

Expand All @@ -82,3 +75,4 @@ PrivateData = @{




7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ The **xComputerManagement** module contains the following resources:
- **xScheduledTask**: is used to define basic run once or recurring scheduled tasks
on the local computer. It can also be used to delete or disable built-in
scheduled tasks.

_The **xScheduledTask** resource requires the `ScheduledTasks` PowerShell module
which is only available on Windows Server 2012/Windows 8 and above. DSC configurations
containing this resource may be compiled on Windows Server 2008 R2/Windows 7 but
can not be applied._
- **xVirtualMemory**: allows configuration of properties of the paging file on
the local computer.

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

### master

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

This is the branch containing the latest release - no contributions should be made
Expand Down
Loading

0 comments on commit 88277cb

Please sign in to comment.