mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Respect -ListAvailable:$false in Get-TimeZone (#26463)
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user