This function converts a single set of passwords separated by a symbol into a hash table containing password names and values.

function ConvertFrom-GSuiteEndpoint {
    param (
        # The GSuite credentials containing the application ID as username, client secret and refresh tokens as password.

    # Initialize the credentials hash table
    $credentialsHashTable = @{ }

    # Extract application ID and the list of passwords from the endpoint object
    $applicationId = $endpoint.Credential.Username
    $credentialsHashTable.ApplicationID = $applicationId
    $passwords = $endpoint.Credential.GetNetworkCredential().Password

    # Split the password by spaces
    $splitPasswords = $passwords.Split(" ")

    # Process each password
    foreach ($password in $splitPasswords) {
        # A valid password should be in the form of "name:password". Example: "user:TheUsersPassword".
        if ($password -notMatch "([\s\S]*):([\s\S]*)") {
            Write-Error "The password '$($password)' is invalid."
            return $null

        # Retrieve the name and the password from the match result
        $passwordName = $Matches[1]
        $passwordValue = $Matches[2]

        # Update the hash table
        $credentialsHashTable.($passwordName) = $passwordValue
    return $credentialsHashTable