Public/Get-PASAccountList.ps1

Function Get-PASAccountList {
    <#
.SYNOPSIS
    This Function uses the psPAS Module to get admin credentials for the WFM Network
 
.NOTES
    Name: Get-PASAdminCredential
    Author: Luke Hagar
    Version: 1.0
    DateCreated: 5/13/2021
 
.EXAMPLE
    $AdminCredential = Get-PASAdminCredential
 
#>

    
    $wshell = New-Object -ComObject Wscript.Shell
    Try { $Session = Get-PASSession }
    Catch { $Session = $null }
    if (!($Session)) {
        $User = Get-User
        $PVCred = Get-Credential -UserName $User.UserPrincipalName -Message "Provide Credentials for CyberArk Password Vault"
        if ($null -ne $PVCred) {
            $wshell.Popup("Please Approve the Sign in Request on the Microsoft Authenticator app", 0, "Done", 0x1) | Out-Null
            New-PASSession -Credential $PVCred -BaseURI "https://myvault.wholefoods.com" -type RADIUS
        } 
        else {
            Throw "No Credentials Provided"
        }
    }
    Try {
        $PASAccounts = Get-PASAccount
        $wshell.Popup("Please select the Admin account", 0, "Done", 0x1) | Out-Null
        $SelectedAccount = ($PASAccounts | Out-GridView -OutputMode Single) | Sort-Object -Unique
        if ($null -ne $SelectedAccount) {
            Return $SelectedAccount
        }
        else {
            Throw "No Account selected"
        }
    }
    Catch { 
        Install-Dependencies
        Throw "Installed Dependencies, Please run command again"
    }
}