Scripts/Get-BPAObjectProperty.ps1

function Get-BPAObjectProperty {
    <#
        .SYNOPSIS
            Gets AutoMate BPA workflow/task/agent properties if non-inherited values are used. If the inherited values are used, nothing will be returned.
 
        .DESCRIPTION
            Get-BPAObjectProperty gets properties for objects.
 
        .PARAMETER InputObject
            The object(s) to retrieve properties for.
 
        .INPUTS
            Properties for the following objects can be retrieved by this function:
            Workflow
            Task
            Agent
 
        .EXAMPLE
            # Get permissions for workflow "My Workflow"
            Get-BPAWorkflow "My Workflow" | Get-BPAObjectProperty
 
        .NOTES
            Author(s): : David Seibel
            Contributor(s) :
            Date Created : 02/28/2017
            Date Modified : 05/01/2018
 
        .LINK
            https://github.com/davidseibel/PoshBPA
    #>

    [CmdletBinding()]
    param(
        [Parameter(Position = 0, ParameterSetName = "ByPipeline", ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        $InputObject        
    )

    PROCESS {
        foreach ($obj in $InputObject) {
            Write-Verbose "Processing object Name: '$($obj.Name)' Type: '$($obj.TypeName)'"

            if ($obj.TypeName -in @("Workflow","Task","Agent")) {
                Invoke-BPARestMethod -Resource "$([BPATypeDictionary]::($obj.TypeName).RestResource)/$($obj.ID)/properties/get" -RestMethod Get -BPAServer $obj.BPAServer
            } else {
                $unsupportedType = $obj.GetType().FullName
                if ($obj.TypeName) { 
                    $unsupportedType = $obj.TypeName
                } elseif (($null -ne $obj.Type) -and ($obj.Type -ne "")) {
                    $unsupportedType = $obj.Type
                }
                Write-Error -Message "Unsupported input type '$unsupportedType' encountered!" -TargetObject $obj
            }
        }
    }
}