public/Get-CTSnapshot.ps1
Function Get-CTSnapshot { [cmdletBinding( DefaultParameterSetName='Hanwha', #SupportsShouldProcess = $true, ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true, ParameterSetName='Hanwha' )] [String]$IP, [Parameter( Mandatory=$true, ParameterSetName='Hanwha' )] [pscredential]$Credential, [Parameter( Mandatory=$false, ParameterSetName='Hanwha' )] [String]$Channel=0, [Parameter( Mandatory=$true, ParameterSetName='Hanwha' )] [String]$Path ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true Position = 1 ParameterSetName = "Hanwha" Enum = $Script:SupportedCameraModels } } return New-DynamicParameterSet -ParameterTable $DynamicParameters } Begin { Write-Debug "[Get-CTSnapshot] Started" $CameraType = $PSBoundParameters.CameraType if($CameraType -eq 'Hanwha') { #Check for MJPEG Profile $Param = @{ IP = $IP Credential = $Credential CameraType = 'Hanwha' Channel = $Channel ProfileId = 3 } $MediaProfile = Get-CTMediaProfile @Param if($MediaProfile.EncodingType -ne 'MJPEG') { Write-Warning -Message "Adding MJPEG Support to Profile 3" $Param = @{ IP = $IP Credential = $Credential ProfileID = 3 NewName = "Snapshot" Channel = $ch.Channel CameraType = 'Hanwha' Encoding = 'MJPEG' } Update-CTMediaProfile @Param } #Can't use Invoke-HanwhaCommand because we need Invoke-WebRequest $Param = @{ Uri = "https://$IP/stw-cgi/video.cgi?msubmenu=snapshot&action=view&Channel=$Channel&Profile=3" OutFile = $Path UseBasicParsing = $True Credential = $Credential } Invoke-WebRequest @Param } } } |