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
<#
    .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 configuration object.

    .EXAMPLE
    PS> Read-Config
#>

function Read-Config {

    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 (New-Object PSObject -Property @{
        SfCredentials = $SfCredentials
        SfSecurityToken = $SfSecurityToken
        SfOauth = $SfOauth
        IamCredentials = $IamCredentials
        Sandbox = $Sandbox
        Scopes = @("profile","email","read_write")
    })
}