private/Functions/Axis/Get-AxisSnapshot.ps1
Function Get-AxisSnapshot { [cmdletBinding()] Param( [Parameter()] [hashtable]$Object ) <# Object Definition: @{ IP = [String(Mandatory)] Credential = [PSCredential(Mandatory)] Channel = [int] as [String(Optional)] Path = [int] as [String(Mandatory)] } #> Write-Debug "[Get-AxisSnapshot] Started" $Channel = 0 if($Object.ContainsKey('Channel') -and $Object.Channel) { $Channel = $Object.Channel } Write-Debug "Channel:$Channel" #Check for MJPEG Profile $obj = @{ IP = $Object.IP Credential = $Object.Credential Channel = $Channel ProfileId = 3 } $MediaProfile = Get-AxisMediaProfile $obj if($MediaProfile.EncodingType -ne 'MJPEG') { Write-Warning -Message "Adding MJPEG Support to Profile 3" $obj = @{ IP = $Object.IP Credential = $Object.Credential ProfileID = 3 NewName = "Snapshot" Channel = $Channel Encoding = 'MJPEG' } Update-AxisMediaProfile $obj } #Can't use Invoke-AxisCommand because we need Invoke-WebRequest $Param = @{ Uri = "https://$($Object.IP)/stw-cgi/video.cgi?msubmenu=snapshot&action=view&Channel=$Channel&Profile=3" OutFile = $Object.OutFile Credential = $Object.Credential } if($PSVersionTable.PSVersion.Major -gt 5) { $Param.Add('SkipCertificateCheck',$true) } else { $Param.Add('UseBasicParsing',$true) } $NULL = Invoke-WebRequest @Param } |