Skip to content

Commit ae1e1bf

Browse files
authored
Fix PendingReboot Localized Data issue - Fixes #350 (#351)
- ScheduleTask - Fixed issue with `ExecuteAsCredential` not returning fully qualified username on newer versions of Windows 10 and Windows Server 2019 - Fixes Issue #352. - PendingReboot - Fixed issue with loading localized data on non en-US operating systems - Fixes Issue #350.
1 parent 1e924d6 commit ae1e1bf

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- ScheduledTask
1111
- Fixed issue with disabling scheduled tasks that have "Run whether user is
1212
logged on or not" configured - Fixes [Issue #306](https://github.com/dsccommunity/ComputerManagementDsc/issues/306).
13+
- Fixed issue with `ExecuteAsCredential` not returning fully qualified username
14+
on newer versions of Windows 10 and Windows Server 2019 - Fixes [Issue #352](https://github.com/dsccommunity/ComputerManagementDsc/issues/352).
15+
- PendingReboot
16+
- Fixed issue with loading localized data on non en-US operating systems -
17+
Fixes [Issue #350](https://github.com/dsccommunity/ComputerManagementDsc/issues/350).
1318

1419
## [8.4.0] - 2020-08-03
1520

source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
1818
when determining if reboot is required. This is stored in a separate
1919
data file so that it can also be used in testing.
2020
#>
21-
$script:localizedResourceData = Import-LocalizedData `
22-
-BaseDirectory $PSScriptRoot `
23-
-FileName 'DSC_PendingReboot.data.psd1'
21+
$script:localizedResourceData = Get-LocalizedData `
22+
-DefaultUICulture 'en-US' `
23+
-FileName 'DSC_PendingReboot.data'
2424
$script:rebootTriggers = $script:localizedResourceData.RebootTriggers
2525
<#
2626
.SYNOPSIS

source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,19 @@ function Test-TargetResource
14401440
# The password of the execution credential can not be compared
14411441
$username = $ExecuteAsCredential.UserName
14421442
$PSBoundParameters['ExecuteAsCredential'] = $username
1443+
1444+
<#
1445+
Windows Server 2019 and newer versions of Windows 10 don't return fully qualified
1446+
username in the current ExecuteAsCredential if it is the local machine. Therefore
1447+
the compare will fail and show a false positive (see Issue #350).
1448+
1449+
To resolve this, add the computer name if it is missing and if it was passed in the
1450+
ExecuteAsCredential parameter.
1451+
#>
1452+
if ($username -cmatch '\\' -and $currentValues.ExecuteAsCredential -cnotmatch '\\')
1453+
{
1454+
$currentValues.ExecuteAsCredential = "$ENV:COMPUTERNAME\$($currentValues.ExecuteAsCredential)"
1455+
}
14431456
}
14441457
else
14451458
{
@@ -1832,11 +1845,12 @@ function Get-CurrentResource
18321845
$PrincipalId = 'UserId'
18331846
}
18341847

1835-
<# The following workaround is needed because Get-StartedTask currently returns NULL for the value
1836-
of $settings.MultipleInstances when the started task is set to "Stop the existing instance".
1837-
https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/40685125-bug-get-scheduledtask-returns-null-for-value-of-m
1838-
#>
1848+
<# The following workaround is needed because Get-StartedTask currently returns NULL for the value
1849+
of $settings.MultipleInstances when the started task is set to "Stop the existing instance".
1850+
https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/40685125-bug-get-scheduledtask-returns-null-for-value-of-m
1851+
#>
18391852
$MultipleInstances = [System.String] $settings.MultipleInstances
1853+
18401854
if ([System.String]::IsNullOrEmpty($MultipleInstances))
18411855
{
18421856
if ($task.settings.CimInstanceProperties.Item('MultipleInstances').Value -eq 3)

0 commit comments

Comments
 (0)