Set TimeZone - PowerShell
Overview
Set-TimeZone assigns a specified time zone to the system, changing the display and operation of time-related functions to match the time in that zone. This is particularly useful in geographically dispersed or multi-user environments to ensure accurate timekeeping.
Syntax
Set-TimeZone [-Name] <String> [-Confirm] [-WhatIf] [-ErrorAction <Action>] [-ErrorVariable <String>] [-OutBuffer <Object>] [-OutVariable <String>]
Options/Flags
| Option/Flag | Required | Purpose | Default Value |
|—|—|—|—|
| -Name
| Yes | Time zone name to set. | N/A |
Examples
Example 1: Set Time Zone to UTC
Set-TimeZone -Name Coordinated Universal Time
Example 2: Set Time Zone to Pacific Time
Set-TimeZone -Name Pacific Time (US & Canada)
Example 3: Confirm Time Zone Change
Set-TimeZone -Name Eastern Time (US & Canada) -Confirm
Common Issues
- Incorrect Time Zone Name: Ensure the specified time zone name is valid. Use
Get-TimeZone
to view available options. - Unauthorized Access: Users may not have sufficient privileges to change the system time zone. Grant necessary permissions to allow the operation.
Integration
Combine Set-TimeZone with:
- Get-TimeZone: To retrieve a list of available time zones.
- New-ScheduledTask: To schedule tasks based on a specific time zone.
- Invoke-WebRequest: To interact with remote servers using the correct time offset.
Related Commands
- Get-TimeZone
- ConvertTo-TimeZone
- ConvertFrom-TimeZone