private/Functions/Axis/Get-AxisCapability.ps1

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

        [Parameter(
            Mandatory=$false,
            ParameterSetName = "Raw"
        )]
        [String]$Path,

        [Parameter(
            Mandatory=$false,
            ParameterSetName = "Raw"
        )]
        [switch]$Raw,

        [Parameter(
            Mandatory=$false,
            ParameterSetName = "Preset"
        )]
        [string]$Channel,

        [Parameter(
            Mandatory=$true,
            ParameterSetName = "Preset"
        )]
        [Parameter(
            Mandatory=$true,
            ParameterSetName = "Raw"
        )]
        [pscredential]$Credential
    )
    DynamicParam {
        $DynamicParameters = @{
            Capability = @{
                Mandatory = $false
                #Position = 1
                ParameterSetName = "Preset"
                Enum = @(
                    'SimpleFocus'
                )
            }
        }

        return New-DynamicParameterSet -ParameterTable $DynamicParameters
    }
    Begin {
        #Raw values should just be returned straight
        if($PSCmdlet.ParameterSetName -eq 'Raw') {
            $CamCmd = @{
                URI = "https://$IP/stw-cgi/attributes.cgi/$Path"
                Credential = $Credential
            }
            return Invoke-AxisCommand @CamCmd
        }

        #Preset Values
        $Capability = $PSBoundParameters.Capability
        switch($Capability) {
            SimpleFocus {
                $CamCmd = @{
                    URI = "https://$IP/stw-cgi/attributes.cgi/attributes/Image/Support"
                    Credential = $Credential
                }
                $result = Invoke-AxisCommand @CamCmd
                
                #Even though Single lens cameras will always have 1 channel, format is kept consistent
                if($Channel -eq 'All') {
                    $ChannelArray = $result.category.channel.number
                    $output = @()
                    
                    #Iterate through the Channels
                    ForEach ($ch in $ChannelArray) {
                        $ChannelCapabilities = ($result.category.channel | Where-Object { $_.number -eq $ch }).attribute

                        if($ChannelCapabilities) {
                            $output += [pscustomobject]@{
                                Channel = $ch
                                SimpleFocus = ($ChannelCapabilities | Where-Object {$_.name -eq 'SimpleFocus'}).value
                            }
                        }
                        else {
                            #If the Channel doesn't exist, the capability sure don't
                            $output += [pscustomobject]@{
                                Channel = $ch
                                SimpleFocus = $false
                            }
                        }
                    }

                    return $output
                }
                #For Single Channel Requests
                else {
                    $ChannelCapabilities = ($result.category.channel | Where-Object { $_.number -eq $Channel }).attribute
                    if($ChannelCapabilities) {
                        return [System.Convert]::ToBoolean(($ChannelCapabilities | Where-Object {$_.name -eq 'SimpleFocus'}).value)
                    }
                }
            }
        }
    }
}