public/Update-CTMediaProfile.ps1

<#
https://$($ip)/stw-cgi/media.cgi?msubmenu=videoprofile&action=update
EncodingType=H265
Resolution=$($resX)x$($resY)
FrameRate=$($framerate)
Bitrate=5120
H265.PriorityType=FrameRate
H265.GOVLength=8
H265.DynamicGOVLength=8
H265.EntropyCoding=CABAC
H265.Profile=Main
H265.BitrateControlType=VBR
H265.SmartCodecEnable=False
H265.DynamicFPSEnable=False
H265.MinDynamicFPS=1
Profile=1
Channel=$($channelnum)
#>


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

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

        [Parameter(
            Mandatory=$true,
            ParameterSetName='All'
        )]
        [String]$ProfileID,

        [Parameter(
            Mandatory=$false,
            ParameterSetName='All'
        )]
        [String]$NewName,

        [Parameter(
            Mandatory=$false,
            ParameterSetName='All'
        )]
        [String]$FrameRate,

        [Parameter(
            Mandatory=$false,
            ParameterSetName='All'
        )]
        [String]$BitRate,

        [Parameter(
            Mandatory=$true,
            ParameterSetName='All'
        )]
        [String]$Channel

    )
    DynamicParam {
        $DynamicParameters = @{
            CameraType = @{
                Mandatory = $true
                Position = 1
                ParameterSetName = "All"
                Enum = $Script:SupportedCameraModels
            }
            Encoding = @{
                Mandatory = $true
                Position = 1
                ParameterSetName = "All"
                Enum = @(
                    'MJPEG'
                    'H264'
                    'MPEG4'
                    'H265'
                )
            }
            Resolution = @{
                Mandatory = $false
                Position = 1
                ParameterSetName = "All"
                Enum = $StandardResolutions
            }
            PriorityType = @{
                Mandatory = $false
                Position = 1
                ParameterSetName = "All"
                Enum = @(
                    'FrameRate'
                    'Bitrate'
                )
                Value = 'FrameRate'
            }
            BitrateControlType = @{
                Mandatory = $false
                Position = 1
                ParameterSetName = "All"
                Enum = @(
                    'CBR'
                    'VBR'
                )
                Value = 'VBR'
            }
            H26xProfile = @{
                Mandatory = $false
                Position = 1
                ParameterSetName = "All"
                Enum = @(
                    'BaseLine'
                    'Main'
                    'High'
                    'Main10'
                    'MainStillPicture+'
                )
                Value = 'Main'
            }
        }

        return New-DynamicParameterSet -ParameterTable $DynamicParameters
    }
    Begin {
        Write-Debug "[Update-CTMediaProfile] Started"
        $CameraType = $PSBoundParameters.CameraType
        $Encoding = $PSBoundParameters.Encoding
        $Resolution = $PSBoundParameters.Resolution
        $PriorityType = $PSBoundParameters.PriorityType
        $BitrateControlType = $PSBoundParameters.BitrateControlType
        $H26xProfile = $PSBoundParameters.H26xProfile

        #Validate Parameters
        if($H26xProfile -and !$Encoding.contains('H26')) {
            Throw "Cannot set H.26x profile on non-H.26x Encoding"
        }

        if($CameraType -eq 'Hanwha') {
            #Build Submission Object
            $obj = @{
                IP = $IP
                Credential = $Credential
                ProfileID = $ProfileID
                NewName = $NewName
                FrameRate = $FrameRate
                BitRate = $BitRate
                Channel = $Channel
                Encoding = $Encoding
                Resolution = $Resolution
                PriorityType = $PriorityType
                BitrateControlType = $BitrateControlType
                H26xProfile = $H26xProfile
            }

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