Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueHO authored Apr 9, 2021
2 parents db4916d + e181574 commit 687d6a4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ The format is based on and uses the types of changes according to [Keep a Change
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- WindowsCapability
- Added the 'Source' parameter for Add-WindowsCapability as an
optional parameter - Fixes [Issue #361](https://github.com/dsccommunity/ComputerManagementDsc/issues/361)

### Added

Expand All @@ -28,7 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed issue with disabling scheduled tasks that have "Run whether user is
logged on or not" configured - Fixes [Issue #306](https://github.com/dsccommunity/ComputerManagementDsc/issues/306).
- Fixed issue with `ExecuteAsCredential` not returning fully qualified username
on newer versions of Windows 10 and Windows Server 2019 - Fixes [Issue #352](https://github.com/dsccommunity/ComputerManagementDsc/issues/352).
on newer versions of Windows 10 and Windows Server 2019 for both local
accounts and domain accounts - Fixes [Issue #352](https://github.com/dsccommunity/ComputerManagementDsc/issues/352).
- Fixed issue with `StartTime` failing Test-Resource if not specified in the
resource - Fixes [Issue #148](https://github.com/dsccommunity/ComputerManagementDsc/issues/148).
- PendingReboot
Expand Down
13 changes: 11 additions & 2 deletions source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1448,9 +1448,18 @@ function Test-TargetResource
To resolve this, add the computer name if it is missing and if it was passed in the
ExecuteAsCredential parameter.
#>
if ($username -cmatch '\\' -and $currentValues.ExecuteAsCredential -cnotmatch '\\')
if ($username -match "$ENV:COMPUTERNAME\\" -and $currentValues.ExecuteAsCredential)
{
$currentValues.ExecuteAsCredential = "$ENV:COMPUTERNAME\$($currentValues.ExecuteAsCredential)"
$currentValues.ExecuteAsCredential = Set-DomainNameInAccountName `
-AccountName $currentValues.ExecuteAsCredential `
-DomainName $ENV:COMPUTERNAME
}

if ($username -match "$ENV:USERDOMAIN\\" -and $currentValues.ExecuteAsCredential)
{
$currentValues.ExecuteAsCredential = Set-DomainNameInAccountName `
-AccountName $currentValues.ExecuteAsCredential `
-DomainName $ENV:USERDOMAIN
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ function Get-TargetResource
Specifies the full path and file name to log to. This is a write
only parameter that is used when updating the status of a Windows
Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'.
.PARAMETER Source
Specifies the location of the files that are required to add a Windows
capability package to an image. You can specify the Windows directory
of a mounted image or a running Windows installation that is shared on the network.
#>
function Set-TargetResource
{
Expand All @@ -104,7 +109,11 @@ function Set-TargetResource

[Parameter()]
[System.String]
$LogPath
$LogPath,

[Parameter()]
[System.String]
$Source
)

Write-Verbose -Message ($script:localizedData.SetTargetResourceStartMessage -f $Name)
Expand All @@ -127,6 +136,12 @@ function Set-TargetResource
if ($Ensure -ne $currentState.Ensure)
{
Write-Verbose -Message ($script:localizedData.SetTargetRemoveMessage -f $Name)

if ($PSBoundParameters.ContainsKey('Source'))
{
$PSBoundParameters.Remove('Source')
}

$null = Remove-WindowsCapability -Online @PSBoundParameters
}
}
Expand Down Expand Up @@ -184,7 +199,11 @@ function Test-TargetResource

[Parameter()]
[System.String]
$LogPath
$LogPath,

[Parameter()]
[System.String]
$Source
)

$inDesiredState = $true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class DSC_WindowsCapability : OMI_BaseResource
[Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure;
[Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is 'WarningsInfo'."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel;
[Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is '%WINDIR%\\Logs\\Dism\\dism.log'.")] String LogPath;
[Write, Description("Specifies the location of the files that are required to add a Windows capability package to an image. You can specify the Windows directory of a mounted image or a running Windows installation that is shared on the network.")] String Source;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<#PSScriptInfo
.VERSION 1.0.0
.GUID 369d465e-244c-4789-90a6-6f3387e4c85a
.AUTHOR DSC Community
.COMPANYNAME DSC Community
.COPYRIGHT Copyright the DSC Community contributors. All rights reserved.
.TAGS DSCConfiguration
.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE
.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES First version.
.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core
#>

#Requires -module ComputerManagementDsc

<#
.DESCRIPTION
Example script that adds the Windows Capability OpenSSH.Client~~~~0.0.1.0
and set the LogLevel to log Errors only and write the Logfile to Path C:\Temp.
This also uses the Source path for the installation.
#>
Configuration WindowsCapability_AddWindowsCapabilitywithLogLevelLogPathandSource_Config
{
Import-DSCResource -ModuleName ComputerManagementDsc

Node localhost
{
WindowsCapability OpenSSHClient
{
Name = 'OpenSSH.Client~~~~0.0.1.0'
Ensure = 'Present'
LogLevel = 'Errors'
LogPath = 'C:\Temp\Logfile.log'
Source = 'F:\Source\FOD\LanguagesAndOptionalFeatures'
}
}
}
1 change: 1 addition & 0 deletions tests/Integration/DSC_WindowsCapability.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Configuration DSC_WindowsCapability_Config
LogLevel = $Node.LogLevel
LogPath = $Node.LogPath
Ensure = $Node.Ensure
Source = $Node.Source
}
}
}

0 comments on commit 687d6a4

Please sign in to comment.