Skip to content

Commit

Permalink
Merge pull request #220 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 6.4.0.0 of ComputerManagementDsc
  • Loading branch information
kwirkykat authored May 15, 2019
2 parents 9f89bfd + 63d5321 commit 4aef7ff
Show file tree
Hide file tree
Showing 95 changed files with 590 additions and 449 deletions.
12 changes: 0 additions & 12 deletions .vscode/RunAllTests.ps1

This file was deleted.

19 changes: 0 additions & 19 deletions .vscode/launch.json

This file was deleted.

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

## Unreleased

## 6.4.0.0

- ScheduledTask:
- IdleWaitTimeout returned from Get-TargetResource always null - Fixes [Issue #186](https://github.com/PowerShell/ComputerManagementDsc/issues/186).
- Added BuiltInAccount Property to allow running task as one of the build in
service accounts - Fixes [Issue #130](https://github.com/PowerShell/ComputerManagementDsc/issues/130).
- Refactored module folder structure to move resource to root folder of
repository and remove test harness - fixes [Issue #188](https://github.com/PowerShell/ComputerManagementDsc/issues/188).
- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md and
linked to it from README.MD instead.
- Updated test header for all unit tests to version 1.2.4.
- Updated test header for all imtegration to version 1.3.3.
- Enabled example publish to PowerShell Gallery by adding `gallery_api`
environment variable to `AppVeyor.yml`.

## 6.3.0.0

- Correct PSSA custom rule violations - fixes [Issue #209](https://github.com/PowerShell/ComputerManagementDsc/issues/209).
Expand Down
6 changes: 6 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code of conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional
questions or comments.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
# Version number of this module.
moduleVersion = '6.3.0.0'
moduleVersion = '6.4.0.0'

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

# ReleaseNotes of this module
ReleaseNotes = '- Correct PSSA custom rule violations - fixes [Issue 209](https://github.com/PowerShell/ComputerManagementDsc/issues/209).
- Correct long example filenames for PowerShellExecutionPolicy examples.
- Opted into Common Tests "Required Script Analyzer Rules",
"Flagged Script Analyzer Rules", "New Error-Level Script Analyzer Rules"
"Custom Script Analyzer Rules" and "Relative Path Length" -
fixes [Issue 152](https://github.com/PowerShell/ComputerManagementDsc/issues/152).
- PowerPlan:
- Added support to specify the desired power plan either as name or guid.
Fixes [Issue 59](https://github.com/PowerShell/ComputerManagementDsc/issues/59)
- Changed the resource so it uses Windows APIs instead of WMI/CIM
(Workaround for Server 2012R2 Core, Nano Server, Server 2019 and Windows 10).
Fixes [Issue 155](https://github.com/PowerShell/ComputerManagementDsc/issues/155)
and [Issue 65](https://github.com/PowerShell/ComputerManagementDsc/issues/65)
ReleaseNotes = '- ScheduledTask:
- IdleWaitTimeout returned from Get-TargetResource always null - Fixes [Issue 186](https://github.com/PowerShell/ComputerManagementDsc/issues/186).
- Added BuiltInAccount Property to allow running task as one of the build in
service accounts - Fixes [Issue 130](https://github.com/PowerShell/ComputerManagementDsc/issues/130).
- Refactored module folder structure to move resource to root folder of
repository and remove test harness - fixes [Issue 188](https://github.com/PowerShell/ComputerManagementDsc/issues/188).
- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md and
linked to it from README.MD instead.
- Updated test header for all unit tests to version 1.2.4.
- Updated test header for all imtegration to version 1.3.3.
- Enabled example publish to PowerShell Gallery by adding `gallery_api`
environment variable to `AppVeyor.yml`.
'

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




File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ $script:localizedData = Get-LocalizedData `
True if the task should be enabled, false if it should be disabled.
Not used in Get-TargetResource.
.PARAMETER BuiltInAccount
Run the task as one of the built in service accounts.
When set ExecuteAsCredential will be ignored and LogonType will be set to 'ServiceAccount'
.PARAMETER ExecuteAsCredential
The credential this task should execute as. If not specified defaults to running
as the local system account. Cannot be used in combination with ExecuteAsGMSA.
Expand Down Expand Up @@ -277,6 +281,11 @@ function Get-TargetResource
[System.Boolean]
$Enable = $true,

[Parameter()]
[ValidateSet('SYSTEM', 'LOCAL SERVICE', 'NETWORK SERVICE')]
[System.String]
$BuiltInAccount,

[Parameter()]
[System.Management.Automation.PSCredential]
$ExecuteAsCredential,
Expand Down Expand Up @@ -511,7 +520,7 @@ function Get-TargetResource
$returnSynchronizeAcrossTimeZone = $false
}

return @{
$result = @{
TaskName = $task.TaskName
TaskPath = $task.TaskPath
StartTime = $startAt
Expand All @@ -538,7 +547,7 @@ function Get-TargetResource
AllowStartIfOnBatteries = -not $settings.DisallowStartIfOnBatteries
Hidden = $settings.Hidden
RunOnlyIfIdle = $settings.RunOnlyIfIdle
IdleWaitTimeout = ConvertTo-TimeSpanStringFromScheduledTaskString -TimeSpan $settings.IdleSettings.IdleWaitTimeout
IdleWaitTimeout = ConvertTo-TimeSpanStringFromScheduledTaskString -TimeSpan $settings.IdleSettings.WaitTimeout
NetworkName = $settings.NetworkSettings.Name
DisallowStartOnRemoteAppSession = $settings.DisallowStartOnRemoteAppSession
StartWhenAvailable = $settings.StartWhenAvailable
Expand All @@ -558,6 +567,13 @@ function Get-TargetResource
EventSubscription = $trigger.Subscription
Delay = ConvertTo-TimeSpanStringFromScheduledTaskString -TimeSpan $trigger.Delay
}

if (($result.ContainsKey('LogonType')) -and ($result['LogonType'] -ieq 'ServiceAccount'))
{
$result.Add('BuiltInAccount', $task.Principal.UserId)
}

return $result
}
}

Expand Down Expand Up @@ -604,6 +620,10 @@ function Get-TargetResource
.PARAMETER Enable
True if the task should be enabled, false if it should be disabled.
.PARAMETER BuiltInAccount
Run the task as one of the built in service accounts.
When set ExecuteAsCredential will be ignored and LogonType will be set to 'ServiceAccount'
.PARAMETER ExecuteAsCredential
The credential this task should execute as. If not specified defaults to running
as the local system account. Cannot be used in combination with ExecuteAsGMSA.
Expand Down Expand Up @@ -786,6 +806,11 @@ function Set-TargetResource
[System.Boolean]
$Enable = $true,

[Parameter()]
[ValidateSet('SYSTEM', 'LOCAL SERVICE', 'NETWORK SERVICE')]
[System.String]
$BuiltInAccount,

[Parameter()]
[System.Management.Automation.PSCredential]
$ExecuteAsCredential,
Expand Down Expand Up @@ -990,7 +1015,7 @@ function Set-TargetResource
-ArgumentName EventSubscription
}

if ($ExecuteAsCredential -and $ExecuteAsGMSA)
if ($ExecuteAsGMSA -and ($ExecuteAsCredential -or $BuiltInAccount))
{
New-InvalidArgumentException `
-Message ($script:localizedData.gMSAandCredentialError) `
Expand Down Expand Up @@ -1245,8 +1270,20 @@ function Set-TargetResource

# Prepare the register arguments
$registerArguments = @{}
$username = $null

if ($PSBoundParameters.ContainsKey('ExecuteAsGMSA'))
if ($PSBoundParameters.ContainsKey('BuiltInAccount'))
{
<#
The validateset on BuiltInAccount has already checked the
non-null value to be 'LOCAL SERVICE', 'NETWORK SERVICE' or
'SYSTEM'
#>
$username = 'NT AUTHORITY\' + $BuiltInAccount
$registerArguments.Add('User', $username)
$LogonType = 'ServiceAccount'
}
elseif ($PSBoundParameters.ContainsKey('ExecuteAsGMSA'))
{
$username = $ExecuteAsGMSA
$LogonType = 'Password'
Expand All @@ -1270,6 +1307,11 @@ function Set-TargetResource
}
else
{
<#
'NT AUTHORITY\SYSTEM' basically gives the schedule task admin
privileges, should we default to 'NT AUTHORITY\LOCAL SERVICE'
instead?
#>
$username = 'NT AUTHORITY\SYSTEM'
$registerArguments.Add('User', $username)
$LogonType = 'ServiceAccount'
Expand Down Expand Up @@ -1332,7 +1374,7 @@ function Set-TargetResource
$scheduledTask.Description = $Description
}

if($scheduledTask.Triggers[0].StartBoundary)
if ($scheduledTask.Triggers[0].StartBoundary)
{
<#
The way New-ScheduledTaskTrigger writes the StartBoundary has issues because it does not take
Expand Down Expand Up @@ -1368,8 +1410,8 @@ function Set-TargetResource

# Register the scheduled task

$registerArguments.Add('TaskName',$TaskName)
$registerArguments.Add('TaskPath',$TaskPath)
$registerArguments.Add('TaskName', $TaskName)
$registerArguments.Add('TaskPath', $TaskPath)
$registerArguments.Add('InputObject', $scheduledTask)

$null = Register-ScheduledTask @registerArguments
Expand Down Expand Up @@ -1427,6 +1469,10 @@ function Set-TargetResource
.PARAMETER Enable
True if the task should be enabled, false if it should be disabled.
.PARAMETER BuiltInAccount
Run the task as one of the built in service accounts.
When set ExecuteAsCredential will be ignored and LogonType will be set to 'ServiceAccount'
.PARAMETER ExecuteAsCredential
The credential this task should execute as. If not specified defaults to running
as the local system account. Cannot be used in combination with ExecuteAsGMSA.
Expand Down Expand Up @@ -1610,6 +1656,11 @@ function Test-TargetResource
[System.Boolean]
$Enable = $true,

[Parameter()]
[ValidateSet('SYSTEM', 'LOCAL SERVICE', 'NETWORK SERVICE')]
[System.String]
$BuiltInAccount,

[Parameter()]
[System.Management.Automation.PSCredential]
$ExecuteAsCredential,
Expand Down Expand Up @@ -1825,12 +1876,44 @@ function Test-TargetResource
return $false
}

if ($PSBoundParameters.ContainsKey('ExecuteAsCredential'))
if ($PSBoundParameters.ContainsKey('BuiltInAccount'))
{
$PSBoundParameters.User = $BuiltInAccount
$currentValues.User = $BuiltInAccount

$PSBoundParameters.ExecuteAsCredential = $BuiltInAccount
$currentValues.ExecuteAsCredential = $BuiltInAccount

$PSBoundParameters['LogonType'] = 'ServiceAccount'
$currentValues['LogonType'] = 'ServiceAccount'
}
elseif ($PSBoundParameters.ContainsKey('ExecuteAsCredential'))
{
# The password of the execution credential can not be compared
$username = $ExecuteAsCredential.UserName
$PSBoundParameters['ExecuteAsCredential'] = $username
}
else
{
# Must be running as System, login type is ServiceAccount
$PSBoundParameters['LogonType'] = 'ServiceAccount'
$currentValues['LogonType'] = 'ServiceAccount'
}

if ($PSBoundParameters.ContainsKey('WeeksInterval') `
-and ((-not $currentValues.ContainsKey('WeeksInterval')) -or ($null -eq $currentValues['WeeksInterval'])))
{
<#
The WeeksInterval parameter of this function defaults to 1,
even though the value of the WeeksInterval property maybe
unset/undefined in the object $currentValues returned from
Get-TargetResouce. To avoid Test-TargetResouce returning false
and generating spurious calls to Set-TargetResouce, default
an undefined $currentValues.WeeksInterval to the value of
$WeeksInterval.
#>
$currentValues.WeeksInterval = $PSBoundParameters['WeeksInterval']
}

if ($PSBoundParameters.ContainsKey('ExecuteAsGMSA'))
{
Expand All @@ -1850,6 +1933,15 @@ function Test-TargetResource
$desiredValues = $PSBoundParameters
$desiredValues.TaskPath = $TaskPath

if ($desiredValues.ContainsKey('Verbose'))
{
<#
Initialise a missing or null Verbose to avoid spurious
calls to Set-TargetResouce
#>
$currentValues.Add('Verbose', $desiredValues['Verbose'])
}

Write-Verbose -Message ($script:localizedData.TestingDscParameterStateMessage)

return Test-DscParameterState -CurrentValues $currentValues -DesiredValues $desiredValues
Expand Down Expand Up @@ -2037,7 +2129,7 @@ Function Get-DateTimeString

$format = (Get-Culture).DateTimeFormat.SortableDateTimePattern

if($SynchronizeAcrossTimeZone)
if ($SynchronizeAcrossTimeZone)
{
$returnDate = (Get-Date -Date $Date -Format $format) + (Get-Date -Format 'zzz')
}
Expand Down
Loading

0 comments on commit 4aef7ff

Please sign in to comment.