|
1 | | -function Convert-TimeZone |
2 | | -{ |
3 | | - <# |
4 | | - .Synopsis |
5 | | - Coverts from a given time zone to the specified time zone. |
6 | | -
|
7 | | - .Description |
8 | | - Coverts from a given time zone to the specified time zone. |
9 | | -
|
10 | | - .Parameter DateTime |
11 | | - A DateTime object will be converted to the new time zone. |
12 | | -
|
13 | | - .Parameter ToTimeZone |
14 | | - The name of the target time zone you wish to convert to. You can get the names by using the -ListTimeZones parameter. |
15 | | -
|
16 | | - .Parameter ListTimeZones |
17 | | - Lists all the time zones that can be used. |
18 | | -
|
19 | | - .Example |
20 | | - Convert-TimeZone -ListTimeZones |
21 | | -
|
22 | | - Id : Dateline Standard Time |
23 | | - DisplayName : (UTC-12:00) International Date Line West |
24 | | - StandardName : Dateline Standard Time |
25 | | - DaylightName : Dateline Daylight Time |
26 | | - BaseUtcOffset : -12:00:00 |
27 | | - SupportsDaylightSavingTime : False |
28 | | -
|
29 | | - Id : UTC-11 |
30 | | - DisplayName : (UTC-11:00) Coordinated Universal Time-11 |
31 | | - StandardName : UTC-11 |
32 | | - DaylightName : UTC-11 |
33 | | - BaseUtcOffset : -11:00:00 |
34 | | - SupportsDaylightSavingTime : False |
35 | | -
|
36 | | - Lists available time zones to convert to. |
37 | | -
|
38 | | - .Example |
39 | | - Convert-TimeZone -DateTime (Get-Date) -ToTimeZone UTC |
40 | | -
|
41 | | - Converts current time to UTC time. |
42 | | -
|
43 | | - .Notes |
44 | | - NAME: Convert-TimeZone |
45 | | - AUTHOR: Matthew Hodgkins |
46 | | - WEBSITE: http://www.hodgkins.net.au |
47 | | -
|
48 | | - #> |
49 | | - |
50 | | - param |
51 | | - ( |
52 | | - [CmdletBinding(DefaultParametersetName = 'Convert Time Zone')] |
53 | | - |
54 | | - [Parameter(Mandatory = $true, |
55 | | - ParameterSetName = 'Convert Time Zone')] |
56 | | - [ValidateNotNull()] |
57 | | - [ValidateNotNullOrEmpty()] |
58 | | - [datetime]$DateTime, |
59 | | - |
60 | | - [Parameter(Mandatory = $true, |
61 | | - ParameterSetName = 'Convert Time Zone')] |
62 | | - [ValidateNotNull()] |
63 | | - [ValidateNotNullOrEmpty()] |
64 | | - [string]$ToTimeZone, |
65 | | - |
66 | | - [Parameter(Mandatory = $false, |
67 | | - ParameterSetName = 'List Time Zones')] |
68 | | - [switch]$ListTimeZones |
69 | | - ) |
70 | | - |
71 | | - # Loading dll for Windows 2003 R2 |
72 | | - [void][System.Reflection.Assembly]::LoadWithPartialName('System.Core') |
73 | | - |
74 | | - # List TimeZones for the user |
75 | | - if ($ListTimeZones) |
76 | | - { |
77 | | - [System.TimeZoneInfo]::GetSystemTimeZones() |
78 | | - return |
79 | | - } |
80 | | - |
81 | | - # Run the Function |
82 | | - else |
83 | | - { |
84 | | - $TimeZoneObject = [System.TimeZoneInfo]::FindSystemTimeZoneById($ToTimeZone) |
85 | | - $TargetZoneTime = [System.TimeZoneInfo]::ConvertTime($DateTime, $TimeZoneObject) |
86 | | - $OutObject = New-Object -TypeName PSObject -Property @{ |
87 | | - LocalTime = $DateTime |
88 | | - LocalTimeZone = $(([System.TimeZoneInfo]::LOCAL).id) |
89 | | - TargetTime = $TargetZoneTime |
90 | | - TargetTimeZone = $($TimeZoneObject.id) |
91 | | - } |
92 | | - |
93 | | - Write-Output $OutObject |
94 | | - } |
95 | | -} |
96 | | - |
97 | 1 | Function Import-XMLConfig |
98 | 2 | { |
99 | 3 | <# |
@@ -135,9 +39,6 @@ Function Import-XMLConfig |
135 | 39 | #Get Metric Send Interval From Config |
136 | 40 | [int]$Config.MetricSendIntervalSeconds = $xmlfile.Configuration.Graphite.MetricSendIntervalSeconds |
137 | 41 |
|
138 | | - # Get the Timezone Of the Graphite Server |
139 | | - $Config.TimeZoneOfGraphiteServer = $xmlfile.Configuration.Graphite.TimeZoneOfGraphiteServer |
140 | | - |
141 | 42 | # Convert Value in Configuration File to Bool for Sending via UDP |
142 | 43 | [bool]$Config.SendUsingUDP = [System.Convert]::ToBoolean($xmlfile.Configuration.Graphite.SendUsingUDP) |
143 | 44 |
|
|
0 commit comments