private/Functions/Hanwha/Set-HanwhaMotion.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 Set-HanwhaMotion {
    [cmdletBinding()]
    Param(
        [Parameter()]
        [hashtable]$Object
    )
    
    <#
    Object Definition:
    @{
        IP = [String(Mandatory)]
        Credential = [PSCredential(Mandatory)]
        Channel = [int] as [String(Mandatory)]
        MotionHighlight as [String(Optional)]
        DetectionType as [String(Optional)]
    }
    #>


    #Set basic Paramters for Invoke-HanwhaCommand
    $CamCmd = @{
        Arguments = @{
            IP = $Object.IP
            Menu = 'eventsources'
            SubMenu = 'videoanalysis2'
            Action = 'set'
            Parameters = @()
        }
        Credential = $Object.Credential
    }
    
    #Need to add Get-HanwhaCapability here

    #Add Action Parameters
    if($Object.MotionHighlight -and $Object.DetectionType -eq 'Off') {
        Throw "MotionDetection must be enabled to use Highlighting"
    }
    
    $CamCmd.Arguments.Parameters += "Channel=$($Object.Channel)"
    if($Object.DetectionType -eq 'All') {
        $CamCmd.Arguments.Parameters += "DetectionType=MDAndIV"
    }
    else {
        $CamCmd.Arguments.Parameters += "DetectionType=$($Object.DetectionType)"
    }
    
    if($Object.MotionHighlight) {
        $CamCmd.Arguments.Parameters += "DetectionResultOverlay=$($Object.MotionHighlight)"
    }

    Invoke-HanwhaCommand @CamCmd
}