ps/Modules/Alkami.DevOps.Inventory/Public/Get-TimeConfiguration.ps1

43 lines
1.2 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-TimeConfiguration {
<#
.SYNOPSIS
Returns an OrderedDictionary that Represents the Time Configuration.
#>
[CmdletBinding()]
Param()
$logLead = (Get-LogLeadName);
$providerStopWatch = [System.Diagnostics.StopWatch]::StartNew()
$timeSettingDictionary = New-Object System.Collections.Specialized.OrderedDictionary
$timeDetails = New-Object System.Collections.Specialized.OrderedDictionary
Write-Verbose "$logLead : [$($providerStopWatch.Elapsed)] : Getting Time Configuration Details"
try {
$dateTime = Get-Date
$timeZone = Get-TimeZone
$timeDetails = New-Object PSObject -Property @{
"CurrentTime" = $dateTime.ToLongTimeString()
"CurrentDate" = $dateTime.Date
"CurrentTicks" = $dateTime.Ticks
"TimeZoneId" = $timeZone.Id
"TimeZoneName" = $timeZone.StandardName
"BaseUtcOffset" = $timeZone.BaseUtcOffset
}
}
catch {
$timeDetails["Error"] = $_.Exception.Message
}
$timeSettingDictionary.Add("TimeConfiguration", $timeDetails)
Write-Verbose "$logLead : [$($providerStopWatch.Elapsed)] : Provider Complete"
$providerStopWatch.Stop()
return $timeSettingDictionary
}