Public/Read-Config.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
58
<#
    .SYNOPSIS
    Read the org configuration from the user

    .DESCRIPTION
    This will prompt the user for the salesforce/hsdp configuration required and return an object with that information.

    .INPUTS
    None. You cannot pipe objects to Read-Config.

    .OUTPUTS
    The new PSCustomObject configuration object.

    .EXAMPLE
    PS> Read-Config
#>

function Read-Config {

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param()

    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)"
        Write-Host "===== SFDC Username and Password"
        $SfCredentials = Get-Credential

        $SfSecurityToken = Read-Host -Prompt "SFDC Security Token"

        Write-Host "===== SFDC Oauth Consumer Key and Secret"
        $SfOauth = Get-Credential

        Write-Host "===== IAM Username and Password"
        $IamCredentials = Get-Credential

        $Sandbox = $false
        if ((Read-Host -Prompt "Sandbox? (Y/N)") -eq "Y") {
            $Sandbox = $true
        }

        Write-Output @{
            SfCredentials   = $SfCredentials
            SfSecurityToken = $SfSecurityToken
            SfOauth         = $SfOauth
            IamCredentials  = $IamCredentials
            Sandbox         = $Sandbox
            Scopes          = @("profile", "email", "read_write")
        }
    }
}