Scripts/Get-BPAObject.ps1

function Get-BPAObject {
    <#
        .SYNOPSIS
            Retrieves any BPA object by ID.
         
        .DESCRIPTION
            Get-BPAObject allows search for any BPA object by its ID when the construct type is not known.
         
        .PARAMETER ID
            The ID to search for.
         
        .PARAMETER Types
            The construct types to search, all are searched by default.
         
        .EXAMPLE
            Get-BPAObject -ID "{1525ea3b-45cc-4ee1-9b34-8ea855c3b299}"
         
        .NOTES
            Author(s): : David Seibel
            Contributor(s) :
            Date Created : 02/09/2018
            Date Modified : 06/07/2018
 
        .LINK
            https://github.com/davidseibel/PoshBPA
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        $ID,

        [ValidateNotNullOrEmpty()]
        [BPAConstructType[]]$Types = @([BPAConstructType]::Workflow, `
                                       [BPAConstructType]::Task, `
                                       [BPAConstructType]::Process, `
                                       [BPAConstructType]::Condition, `
                                       [BPAConstructType]::Agent, `
                                       [BPAConstructType]::AgentGroup, `
                                       [BPAConstructType]::User, `
                                       [BPAConstructType]::UserGroup, `
                                       [BPAConstructType]::Folder
                                      )
    )

    $filterSet = @{Property = "ID"; Comparator = "="; Value = $ID}
    foreach ($type in $Types) {
        foreach ($server in $global:BPAConnectionInfo.Server) {
            $resource = Format-BPAUri -Path "$(([BPATypeDictionary]::($type)).RestResource)/index" -FilterSet $filterSet
            if (Invoke-BPARestMethod -Resource $resource -BPAServer $server) {
                Invoke-BPARestMethod -Resource "$(([BPATypeDictionary]::($type)).RestResource)/$ID/get" -BPAServer $server
            }
        }
    }
}