public/Set-CTMotion.ps1

Function Set-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,

        [Parameter(
            Mandatory=$false,
            ParameterSetName='All'
        )]
        [switch]$MotionHighlight #DetectionResultOverlay

    )
    DynamicParam {
        $DynamicParameters = @{
            CameraType = @{
                Mandatory = $true
                Position = 1
                ParameterSetName = "All"
                Enum = $Script:SupportedCameraModels
            }

            DetectionType = @{
                Mandatory = $false
                Position = 1
                ParameterSetName = "All"
                Enum = @(
                    'MotionDetection'
                    'IntelligentVideo'
                    'All' #MDAndIV
                    'Off'
                )
                Value = "MotionDetection"
            }
        }

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

        #Build Submission Object
        $obj = @{
            IP = $IP
            Credential = $Credential
            Channel = $Channel
            MotionHighlight = $MotionHighlight
            DetectionType = $DetectionType
        }

        #Choose Camera Model
        Switch ($CameraType) {
            Hanwha {
                return Set-HanwhaMotion -Object $obj
            }
        }
    }
}