Skip to content

Get-GSUserLicense issue #357

Open
Open
@pompushko

Description

@pompushko

Hello

function SearchGSuiteUserLicenses($UserEmail)
{
    Write-Color @DisplayConsole "[i] ", "Working with: ", $UserEmail -Color White, White, Green
    $AccountGSuiteLicenses = $null
    # Check GSuite Licenses
    Try
    {
        $AccountGSuiteLicenses = Get-GSUserLicense -User $UserEmail -SkuId G-Suite-Enterprise -Verbose
    }
    Catch
    {
        $ErrorMessage = $_.Exception.Message
        Write-Color @DisplayConsole "[i] ", "Error: ", $ErrorMessage -Color White, White, Red
    }

    Try
    {
        $AccountGSuiteLicenses += Get-GSUserLicense -User $UserEmail -SkuId Google-Vault-Former-Employee -Verbose
    }
    Catch
    {
        $ErrorMessage = $_.Exception.Message
        Write-Color @DisplayConsole "[i] ", "Error: ", $ErrorMessage -Color White, White, Red
    }


    if ($AccountGSuiteLicenses -ne $null){
        Write-Color @DisplayConsole "[i] ", "License found: ", (($AccountGSuiteLicenses | Select-Object -Expand SkuName) -join ', ') -Color White, White, Green
        return (($AccountGSuiteLicenses | Select-Object -Expand SkuName) -join ', ')
    }
    else{
        return $null
    }
}
[2021-08-06 11:43:40] [i] Working with: [email protected]
VERBOSE: Getting License SKU 'G-Suite-Enterprise' for User '[email protected]'
VERBOSE: Getting License SKU 'Google-Vault-Former-Employee' for User '[email protected]'
Get-GSUserLicense : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
User does not have a license for specified sku and product [404]
Errors [
	Message[User does not have a license for specified sku and product] Location[ - ] Reason[notFound] Domain[global]
]
"
At line:18 char:35
+ ... Licenses += Get-GSUserLicense -User $UserEmail -SkuId Google-Vault-Fo ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSUserLicense
 
[2021-08-06 11:43:40] [i] Error: Method invocation failed because [Google.Apis.Licensing.v1.Data.LicenseAssignment] does not contain a method named 'op_Addition'.
[2021-08-06 11:43:40] [i] License found: Google Workspace Enterprise Plus 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions