Skip to content

Commit 2f11115

Browse files
committed
Final tweaks to meet HQRM for TimeZone
1 parent 946e02d commit 2f11115

3 files changed

Lines changed: 15 additions & 19 deletions

File tree

Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,10 @@ function Get-TimeZoneId
364364
-Namespace root\cimv2).StandardName
365365
}
366366

367-
Write-Verbose -Message ($LocalizedData.CurrentTimeZoneMessage `
368-
-f $timeZone)
367+
Write-Verbose -Message ($LocalizedData.CurrentTimeZoneMessage -f $timeZone)
369368

370369
$timeZoneInfo = [System.TimeZoneInfo]::GetSystemTimeZones() |
371-
Where-Object StandardName -eq $timeZone
370+
Where-Object -Property StandardName -EQ $timeZone
372371

373372
return $timeZoneInfo.Id
374373
} # function Get-TimeZoneId
@@ -422,16 +421,14 @@ function Set-TimeZoneId
422421
if (Test-Command -Name 'Add-Type' -Module 'Microsoft.Powershell.Utility')
423422
{
424423
# We can use reflection to modify the time zone.
425-
Write-Verbose -Message ($LocalizedData.SettingTimeZoneMessage `
426-
-f $TimeZoneId, '.NET')
424+
Write-Verbose -Message ($LocalizedData.SettingTimeZoneMessage -f $TimeZoneId, '.NET')
427425

428426
Set-TimeZoneUsingDotNet -TimeZoneId $TimeZoneId
429427
}
430428
else
431429
{
432430
# For anything else use TZUTIL.EXE.
433-
Write-Verbose -Message ($LocalizedData.SettingTimeZoneMessage `
434-
-f $TimeZoneId, 'TZUTIL.EXE')
431+
Write-Verbose -Message ($LocalizedData.SettingTimeZoneMessage -f $TimeZoneId, 'TZUTIL.EXE')
435432

436433
try
437434
{
@@ -444,8 +441,7 @@ function Set-TimeZoneId
444441
} # if
445442
} # if
446443

447-
Write-Verbose -Message ($LocalizedData.TimeZoneUpdatedMessage `
448-
-f $TimeZoneId)
444+
Write-Verbose -Message ($LocalizedData.TimeZoneUpdatedMessage -f $TimeZoneId)
449445
} # function Set-TimeZoneId
450446

451447
<#

Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ try
5454
-Verbose `
5555
-Force `
5656
-ErrorAction Stop
57-
} | Should Not Throw
57+
} | Should -Not -Throw
5858
}
5959

6060
It 'Should be able to call Get-DscConfiguration without throwing' {
61-
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not Throw
61+
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
6262
}
6363
#endregion
6464

6565
It 'Should have set the configuration and all the parameters should match' {
66-
$current = Get-DscConfiguration | Where-Object {
66+
$current = Get-DscConfiguration | Where-Object -FilterScript {
6767
$_.ConfigurationName -eq "$($script:DSCResourceName)_Config"
6868
}
69-
$current.TimeZone | Should Be $configData.AllNodes[0].TimeZone
70-
$current.IsSingleInstance | Should Be $configData.AllNodes[0].IsSingleInstance
69+
$current.TimeZone | Should -Be $configData.AllNodes[0].TimeZone
70+
$current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance
7171
}
7272
}
7373
#endregion

Tests/Unit/MSFT_TimeZone.Tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ try
4646
-CommandName Get-TimeZoneId `
4747
-MockWith { 'Pacific Standard Time' }
4848

49-
$TimeZone = Get-TargetResource `
49+
$timeZone = Get-TargetResource `
5050
-TimeZone 'Pacific Standard Time' `
5151
-IsSingleInstance 'Yes' `
5252
-Verbose
5353

5454
It 'Should return hashtable with Key TimeZone' {
55-
$TimeZone.ContainsKey('TimeZone') | Should -Be $true
55+
$timeZone.ContainsKey('TimeZone') | Should -Be $true
5656
}
5757

5858
It 'Should return hashtable with Value that matches "Pacific Standard Time"' {
59-
$TimeZone.TimeZone = 'Pacific Standard Time'
59+
$timeZone.TimeZone = 'Pacific Standard Time'
6060
}
6161
}
6262

@@ -80,13 +80,13 @@ try
8080
}
8181

8282
It 'Should not call Set-TimeZoneId when Current TimeZone already set to desired State' {
83-
$SystemTimeZone = Get-TargetResource `
83+
$systemTimeZone = Get-TargetResource `
8484
-TimeZone 'Eastern Standard Time' `
8585
-IsSingleInstance 'Yes' `
8686
-Verbose
8787

8888
Set-TargetResource `
89-
-TimeZone $SystemTimeZone.TimeZone `
89+
-TimeZone $systemTimeZone.TimeZone `
9090
-IsSingleInstance 'Yes' `
9191
-Verbose
9292

0 commit comments

Comments
 (0)