Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-GSUserLicense issue #357

Open
pompushko opened this issue Aug 6, 2021 · 1 comment
Open

Get-GSUserLicense issue #357

pompushko opened this issue Aug 6, 2021 · 1 comment

Comments

@pompushko
Copy link

pompushko commented Aug 6, 2021

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 

@Buenno
Copy link

Buenno commented Aug 31, 2023

I think you need to update your module as this function no longer exists. Update and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants