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 67 forks source link

Get-GSUser pipeline workaround #305

Open pompushko opened 4 years ago

pompushko commented 4 years ago

Describe the bug I try get all licenses from suspended accounts and create array. And got WARNING: No license found for USER@DOMAIN.com!

If i put only 1 user all fine: $GCPUsers = Get-GSUser -User "USER@DOMAIN.com" | Select User, PrimaryEmail, CreationTime, LastLoginTime, @{Name='GSuite';Expression={SearchGSuiteUserLicenses($_.User)}}

To Reproduce Steps to reproduce the behavior:

function SearchGSuiteUserLicenses($UserEmail) {

Check GSuite Licenses

$AccountGSuiteLicenses = Get-GSUserLicense -User $UserEmail -CheckAll

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

}

$GCPUsers = Get-GSUser -Filter "IsSuspended -eq '$true'" | Select User, PrimaryEmail, CreationTime, LastLoginTime, @{Name='GSuiteLicense';Expression={SearchGSuiteUserLicenses($_.User)}}

pompushko commented 3 years ago

bump :D

pompushko commented 3 years ago

Nobody have solution?