Respect -ListAvailable:$false in Get-TimeZone (#26463)

This commit is contained in:
yotsuda
2025-11-17 22:04:57 +05:00
committed by GitHub
parent e741cecab3
commit 11d154c673
2 changed files with 7 additions and 1 deletions
@@ -54,7 +54,7 @@ namespace Microsoft.PowerShell.Commands
// make sure we've got the latest time zone settings
TimeZoneInfo.ClearCachedData();
if (this.ParameterSetName.Equals("ListAvailable", StringComparison.OrdinalIgnoreCase))
if (ListAvailable)
{
// output the list of all available time zones
WriteObject(TimeZoneInfo.GetSystemTimeZones(), true);
@@ -71,6 +71,12 @@ Describe "Get-Timezone test cases" -Tags "CI" {
$oneExpectedOffset | Should -BeIn $observedIdList
}
It "Call with -ListAvailable:`$false returns current TimeZoneInfo (not list)" {
$result = Get-TimeZone -ListAvailable:$false
$result | Should -BeOfType TimeZoneInfo
$result.Id | Should -Be ([System.TimeZoneInfo]::Local).Id
}
It "Call Get-TimeZone using ID param and single item" {
$selectedTZ = $TimeZonesAvailable[0]
(Get-TimeZone -Id $selectedTZ.Id).Id | Should -Be $selectedTZ.Id