Get-GSUserLicense issue
pompushko opened this issue · 1 comments
pompushko commented
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: user@DOMAIN.com
VERBOSE: Getting License SKU 'G-Suite-Enterprise' for User 'user@DOMAIN.com'
VERBOSE: Getting License SKU 'Google-Vault-Former-Employee' for User 'user@DOMAIN.com'
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 commented
I think you need to update your module as this function no longer exists. Update and try again.