SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 68 forks source link

Queries per minute per user issue #350

Open pompushko opened 3 years ago

pompushko commented 3 years ago

Hello

How can I manage Quota exceeded issue when working with 5-10 of requests/users ? I extend limit in Google API page. But doesn’t help...

Should I use pause between Get-GSUserLicense commands or any other solution?

[2021-04-01 11:13:30] [e] Cannot assign Google Vault Former Employee license. Please check manually![2021-04-01 11:13:30] [e] Cannot assign Google Vault Former Employee license. Please check manually!Get-GSUserLicense : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestErrorQuota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service 'licensing.googleapis.com' for consumer 'project_number:XXXXXXXXXXXX'. [403]Errors [ Message[Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service 'licensing.googleapis.com' for consumer 'project_number:XXXXXXXXXXXX'.] Location[ - ] Reason[rateLimitExceeded] Domain[usageLimits]]"At ManageExpiredAccounts.ps1:267 char:18+ ... if(!(Get-GSUserLicense -User (get-aduser $UserAccount.SamAccou ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSUserLicense Get-GSUserLicense : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestErrorUser 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 ManageExpiredAccounts.ps1:269 char:22+ ... if(!(Get-GSUserLicense -User (get-aduser $UserAccount.SamAccou ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSUserLicense [2021-04-01 11:13:31] [w] License Google Vault Former Employee is here!

Buenno commented 3 years ago

I'm unable to replicate this error, are you able to share your script?

pompushko commented 3 years ago
 function SearchGSuiteUserLicenses($UserEmail)
{
    # Check GSuite Licenses
    Start-Sleep -s 1
    $AccountGSuiteLicenses = Get-GSUserLicense -User $UserEmail -CheckAll -Verbose

    if ($AccountGSuiteLicenses -ne $null){
        return (($AccountGSuiteLicenses | Select-Object -Expand SkuName) -join ', ')
    }
    else{
        return $null
    }
} 

Btw, I face issue, when user has license, but Get-GSUserLicense show warning with "No license found for user". It happens....