Private/Get-LPLogin.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
<#
.Synopsis
   Prompts the user for credentials
.DESCRIPTION
   Uses Get-Credential to prompt the user and save a PSCredential object with
   the user's LastPass login.
.EXAMPLE
   Get-LPLogin
#>

function Get-LPLogin
{
    [CmdletBinding()]
    Param()

    Process
    {
        Write-Verbose "Prompting the user for credentials"        
        $LPLogin = Get-Credential -Message "Please input your LastPass credentials"

        if (!$LPLogin)
        {
            throw "No credentials provided"
        }

        $script:LPLogin = $LPLogin
        $script:LPLogin
    }
}