Set-TimeZone
Sets the system time zone to a specified time zone.
Синтаксис
Name (по умолчанию)
Set-TimeZone
[-Name] <String>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Id
Set-TimeZone
-Id <String>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
InputObject
Set-TimeZone
[-InputObject] <TimeZoneInfo>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Описание
This cmdlet is only available on the Windows platform.
The Set-TimeZone
cmdlet sets the system time zone to a specified time zone.
Примеры
Example 1: Set the time zone by Id
This example sets the time zone on the local computer to UTC.
Set-TimeZone -Id "UTC"
Id : UTC
HasIanaId : True
DisplayName : (UTC) Coordinated Universal Time
StandardName : Coordinated Universal Time
DaylightName : Coordinated Universal Time
BaseUtcOffset : 00:00:00
SupportsDaylightSavingTime : False
Example 2: Set the time zone by name
This example sets the time zone on the local computer to UTC.
Set-TimeZone -Name 'Coordinated Universal Time' -PassThru
As we saw in the previous example, the Id and the Name of the Time Zone do not always match. The Name parameter must match the StandardName or DaylightName properties of the TimeZoneInfo object.
Note
The time zone names can vary based on the Culture settings in Windows. This example shows the
values for a system set to en-US
.
Example 3 - List all available time zones
A full list of Time Zone IDs can be obtained by running the following command:
Get-TimeZone -ListAvailable
Параметры
-Confirm
Prompts you for confirmation before running the cmdlet.
Свойства параметра
Тип: | SwitchParameter |
Default value: | False |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Aliases: | cf |
Наборы параметров
(All)
Position: | Named |
Обязательно: | False |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | False |
Значение из оставшихся аргументов: | False |
-Id
Specifies the ID of the time zone that this cmdlet sets.
Свойства параметра
Тип: | String |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
Id
Position: | Named |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | True |
Значение из оставшихся аргументов: | False |
-InputObject
Specifies a TimeZoneInfo object to use as input.
Свойства параметра
Тип: | TimeZoneInfo |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
InputObject
Position: | 0 |
Обязательно: | True |
Значение из конвейера: | True |
Значение из конвейера по имени свойства: | False |
Значение из оставшихся аргументов: | False |
-Name
Specifies the name of the time zone that this cmdlet sets. A full list of Time Zone names can be
obtained by running the following command: Get-TimeZone -ListAvailable
.
Свойства параметра
Тип: | String |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
Name
Position: | 0 |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | False |
Значение из оставшихся аргументов: | False |
-PassThru
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Свойства параметра
Тип: | SwitchParameter |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
(All)
Position: | Named |
Обязательно: | False |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | False |
Значение из оставшихся аргументов: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Свойства параметра
Тип: | SwitchParameter |
Default value: | False |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Aliases: | wi |
Наборы параметров
(All)
Position: | Named |
Обязательно: | False |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | False |
Значение из оставшихся аргументов: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Входные данные
String
TimeZoneInfo
Выходные данные
None
By default, this cmdlet returns no output.
TimeZoneInfo
When you use the PassThru parameter, this cmdlet returns a TimeZoneInfo object.
Примечания
PowerShell includes the following aliases for Set-TimeZone
:
- Windows:
stz
This cmdlet is only available on Windows platforms.