public/Get-CTMotion.ps1

#https://$($ip)/stw-cgi/eventsources.cgi?msubmenu=videoanalysis2&action=set&Channel=$($channelnum)&DetectionType=MotionDetection
#https://$($ip)/stw-cgi/eventsources.cgi?msubmenu=videoanalysis2&action=set&Channel=$($channelnum)
#ROI.1.Coordinate=0,0,1919,0,1919,1079,0,1079&ROI.1.SensitivityLevel=80
#ROI.1.Duration=0&
#ROI.1.ThresholdLevel=5
#DetectionType.MotionDetection.DetectionResultOverlay=False

Function Get-CTMotion {
    [cmdletBinding(
        DefaultParameterSetName='All',
        #SupportsShouldProcess = $true,
        ConfirmImpact='high'
        )]
    Param(
        [Parameter(
            Mandatory=$true,
            ParameterSetName='All'
        )]
        [String]$IP,

        [Parameter(
            Mandatory=$true,
            ParameterSetName='All'
        )]
        [pscredential]$Credential,

        [Parameter(
            Mandatory=$false,
            ParameterSetName='All'
        )]
        [String]$Channel
    )
    DynamicParam {
        $DynamicParameters = @{
            CameraType = @{
                Mandatory = $true
                Position = 1
                ParameterSetName = "All"
                Enum = $Script:SupportedCameraModels
            }
        }

        return New-DynamicParameterSet -ParameterTable $DynamicParameters
    }
    Begin {
        Write-Debug "[Get-CTMotion] Started"
        $CameraType = $PSBoundParameters.CameraType

        if($CameraType -eq 'Hanwha') {
            #Set basic Paramters for Invoke-HanwhaCommand
            $CamCmd = @{
                Arguments = @{
                    IP = $IP
                    Menu = 'eventsources'
                    SubMenu = 'videoanalysis'
                    Action = 'view'
                    Parameters = @()
                }
                Credential = $Credential
            }

            if($Channel) {
                $CamCmd.Arguments.Parameters += "Channel=$Channel"
            }

            return (Invoke-HanwhaCommand @CamCmd).VideoAnalysis
        }
    }
}