Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScheduledTask: Resolved inconsistent treatment of BuiltInAccount property. #313

Merged
merged 7 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- WindowsCapability:
- Fix `A parameter cannot be found that matches parameter name 'Ensure'.`
error in `Test-TargetResource` - Fixes [Issue #297](https://github.com/dsccommunity/ComputerManagementDsc/issues/297).

## [8.0.0] - 2020-02-14

### Added
Expand Down Expand Up @@ -41,9 +45,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- WindowsCapability:
- Fix `A parameter cannot be found that matches parameter name 'Ensure'.`
error in `Test-TargetResource` - Fixes [Issue #297](https://github.com/dsccommunity/ComputerManagementDsc/issues/297).
- ScheduledTask:
- Added missing 'NT Authority\' domain prefix when testing tasks that use the BuiltInAccount property - Fixes
[Issue #317](https://github.com/dsccommunity/ComputerManagementDsc/issues/317)

### Security

Expand Down
2 changes: 2 additions & 0 deletions source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,8 @@ function Test-TargetResource

$PSBoundParameters['LogonType'] = 'ServiceAccount'
$currentValues['LogonType'] = 'ServiceAccount'

$PSBoundParameters['BuiltInAccount'] = 'NT AUTHORITY\' + $BuiltInAccount
}
elseif ($PSBoundParameters.ContainsKey('ExecuteAsCredential'))
{
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ try
ExecuteAs = 'ScheduledTaskExecuteAs'
ExecuteAsGroup = 'ScheduledTaskExecuteAsGroup'
OnEvent = 'ScheduledTaskOnEvent'
BuiltInAccount = 'ScheduledTaskServiceAccount'
}

$configData = @{
Expand Down
67 changes: 67 additions & 0 deletions tests/Integration/DSC_ScheduledTask.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,28 @@ Configuration ScheduledTaskOnEventAdd
}
}

Configuration ScheduledTaskServiceAccountAdd
{
Import-DscResource -ModuleName ComputerManagementDsc

node 'localhost'
{
ScheduledTask ScheduledTaskServiceAccountAdd
{
TaskName = 'Test task BuiltInAccount'
TaskPath = '\ComputerManagementDsc\'
Ensure = 'Present'
LogonType = 'ServiceAccount'
BuiltInAccount = 'LOCAL SERVICE'
RunLevel = 'Limited'
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
ScheduleType = 'Once'
RepeatInterval = '00:15:00'
RepetitionDuration = 'Indefinitely'
}
}
}

Configuration ScheduledTaskOnceMod
{
Import-DscResource -ModuleName ComputerManagementDsc
Expand Down Expand Up @@ -429,6 +451,28 @@ Configuration ScheduledTaskOnEventMod
}
}

Configuration ScheduledTaskServiceAccountMod
{
Import-DscResource -ModuleName ComputerManagementDsc

node 'localhost'
{
ScheduledTask ScheduledTaskServiceAccountMod
{
TaskName = 'Test task BuiltInAccount'
TaskPath = '\ComputerManagementDsc\'
Ensure = 'Present'
LogonType = 'ServiceAccount'
BuiltInAccount = 'NETWORK SERVICE'
RunLevel = 'Limited'
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
ScheduleType = 'Once'
RepeatInterval = '00:15:00'
RepetitionDuration = 'Indefinitely'
}
}
}

Configuration ScheduledTaskOnceDel
{
Import-DscResource -ModuleName ComputerManagementDsc
Expand Down Expand Up @@ -604,6 +648,29 @@ Configuration ScheduledTaskOnEventDel
}
}

Configuration ScheduledTaskServiceAccountDel
{
Import-DscResource -ModuleName ComputerManagementDsc

node 'localhost'
{
ScheduledTask ScheduledTaskServiceAccountDel
{
TaskName = 'Test task BuiltInAccount'
TaskPath = '\ComputerManagementDsc\'
Ensure = 'Absent'
LogonType = 'ServiceAccount'
BuiltInAccount = 'LOCAL SERVICE'
RunLevel = 'Limited'
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
ScheduleType = 'Once'
RepeatInterval = '00:15:00'
RepetitionDuration = 'Indefinitely'
ActionWorkingPath = (Get-Location).Path
}
}
}

Configuration ScheduledTaskDisableBuiltIn
{
Import-DscResource -ModuleName ComputerManagementDsc
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/DSC_ScheduledTask.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ try
}
)
Principal = [pscustomobject] @{
UserId = $testParameters.BuiltInAccount
UserId = 'NT AUTHORITY\' + $testParameters.BuiltInAccount
LogonType = 'ServiceAccount'
}
}
Expand Down