public/Get-CTDateTime.ps1
#https://$($ip)/stw-cgi/system.cgi?msubmenu=date&action=set&TimeZoneIndex=$($sitetimezone)&DSTEnable=True #https://$($ip)/stw-cgi/system.cgi?msubmenu=date&action=set&SyncType=NTP&NTPURLList=$($NTPServerIp),time.nist.gov Function Get-CTDateTime { [cmdletBinding( DefaultParameterSetName='All', #SupportsShouldProcess = $true, ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true, ParameterSetName='All' )] [String]$IP, [Parameter( Mandatory=$true, ParameterSetName='All' )] [pscredential]$Credential ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true Position = 1 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } } return New-DynamicParameterSet -ParameterTable $DynamicParameters } Begin { Write-Debug "[Get-CTDateTime] Started" $CameraType = $PSBoundParameters.CameraType if($CameraType -eq 'Hanwha') { #Set basic Paramters for Invoke-HanwhaCommand $CamCmd = @{ Arguments = @{ IP = $IP Menu = 'system' SubMenu = 'date' Action = 'view' Parameters = @() } Credential = $Credential } $result = Invoke-HanwhaCommand @CamCmd $output = [ordered]@{ LocalTime = $result.LocalTime } #Calculate Timezone $tz = $result.TimeZoneIndex if($result.DSTEnable) { $output.Add('TimeZone',$HanwhaTimeZoneIndexs["$($tz)D"]) } else { $output.Add('TimeZone',$HanwhaTimeZoneIndexs["$($tz)S"]) } #Calculate NTP Status if($result.SyncType -eq 'NTP') { $output.Add('NTPServers',$result.NTPURLList) } else { $output.Add('NTPServers','Disabled') } } #Output return [pscustomobject]$output } } |