Public/Invoke-SfObjectGet.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<#
    .SYNOPSIS
    Gets a Salesforce object

    .DESCRIPTION
    Gets a Salesforce object

    .INPUTS
    A Salesforce object Id

    .OUTPUTS
    A PSCustomObject that represent the Salesfsorce object

    .PARAMETER Type
    The type of object

    .PARAMETER Id
    The Salesforce object Id

    .EXAMPLE
    PS> Invoke-SfObjectGet -Type phecc__Device__c -Id "a0N3t000008XXe5EAG"

    .LINK
    Set-Config

    .NOTES
    Assumes config is initialized for org access.
#>

function Invoke-SfObjectGet {

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param(
        [Parameter(Mandatory = $true, Position = 0)]
        [ValidateNotNullOrEmpty()]
        [String]
        $Type,

        [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline)]
        [ValidateNotNullOrEmpty()]
        [String]
        $Id
    )

    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

    process {
        Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
        Invoke-SfApi "/sobjects/$($Type)/$($Id)" -Method Get
    }
}