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-GSGroup and Subdomains #96

Closed
IronKane2 opened this issue Oct 11, 2018 · 18 comments
Closed

Get-GSGroup and Subdomains #96

IronKane2 opened this issue Oct 11, 2018 · 18 comments
Assignees

Comments

@IronKane2
Copy link

Get-GSGroup can find a group in a subdomain by exact email address, but it won't pull up any of these groups in List Mode so it's not filterable. Can a -Domain parameter be added?

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

Hey @IronKane2 - Definitely can be added! Excellent suggestion 😄 Currently, it looks at the Preference value in your PSGSuite config and will set the Domain or Customer scope depending on that. Should have this rolled out by tonight!

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

CC @phatmandrake - I should be able to get Group Query functionality in there as well (@phatmandrake requested this in a previous issue and I actually just got it working with the .NET SDK).

@scrthq scrthq self-assigned this Oct 11, 2018
@IronKane2
Copy link
Author

That'll be awesome. I have a few thousand leftover groups from a former vendor to remove.

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

I'll have you sorted by tonight! 😄

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

Could you test one thing for me and see if Get-GSGroup gives you the list for that specific Subdomain?

# Replace with actual subdomain you're looking for
$thatSubDomain = 'oldvendor.com'

# Store the current config in a var so we can easily revert after testing
$currentConf = Show-PSGSuiteConfig

# Update the config with the specific subdomain you're looking to
# query as the Domain and set Preference to 'Domain'
Set-PSGSuiteConfig -Domain $thatSubDomain -Preference Domain

# Run Get-GSGroup with verbose enabled, you should see the following verbose message:
# "VERBOSE: Getting all G Suite groups for domain '$thatSubDomain'"
$groups = Get-GSGroup -Verbose

# Restore your original config
$currentConf | Set-PSGSuiteConfig

# Explore the Group list to ensure it has the groups you're expecting
($groups | Where-Object {$_.Email -like "*@$($thatSubDomain)"}).Count

@IronKane2
Copy link
Author

PS C:> $groups = Get-GSGroup -Verbose
VERBOSE: Building ServiceAccountCredential from P12Key as user 'srcampbell@djusd.net'
VERBOSE: Getting all G Suite groups for domain 'djusdstudent.org'
Get-GSGroupListPrivate : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Domain not found. [404]
Errors [
Message[Domain not found.] Location[ - ] Reason[notFound] Domain[global]
]
"
At line:74 char:21

  •                 Get-GSGroupListPrivate @PSBoundParameters
    
  •                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSGroupListPrivate

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

🤔 odd! I'm assuming that domain is within the domains your overall customer account owns, correct?

@IronKane2
Copy link
Author

IronKane2 commented Oct 11, 2018

djusd.net is parent domain of djusdstudents.org. I'm SA and have full control of both. I'm able to create djusdstudents.org accounts with New-GSUser for which I'll be eternally grateful.

Path would be djusd.net/djusdstudents.org/...

@IronKane2
Copy link
Author

PS C:> Get-GSGroup 4science_3_e010223_1_p1_210-1415@djusdstudents.org

Group : 4science_3_e010223_1_p1_210-1415@djusdstudents.org
AdminCreated : True
Aliases :
Description : 4Science 3 Crs# E010223 Sec# 1 Period-1 MME-1415
DirectMembersCount : 6
Email : 4science_3_e010223_1_p1_210-1415@djusdstudents.org
ETag : "TN30oD80QTVK45AAxvl_wbzs4vs/ZrY6-AD__jclc0HUrAJQv72fc_A"
Id : 01pxezwc3czu5za
Kind : admin#directory#group
Name : 4Science 3 Crs# E010223 Sec# 1 Period-1 MME-1415
NonEditableAliases :

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

Is the current Preference on your PSGSuite Config set to CustomerID, Domain or blank/not set?

@IronKane2
Copy link
Author

PS C:> Get-GSGroup | ?{$.email -like '*@djusdstudents.org'} returns nothing. While doing Get-GSGroup | ?{$.email -like 'willett'} will pull up djusd.net groups

@IronKane2
Copy link
Author

Preference is set to "Domain"

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

Can you set your preference to "CustomerID" instead and retry that Get-GSGroup? This should list out every group for all domains your customer owns. With Preference set to Domain, it will only search the Domain name listed on the config.

@IronKane2
Copy link
Author

That did it! And it's still scrolling lol

@IronKane2
Copy link
Author

12,688 groups. I believe you've been a big help.

@scrthq
Copy link
Member

scrthq commented Oct 11, 2018

nice! Your original request is still very valid though and it's still on my TODO list to get handled tonight 💪

@scrthq
Copy link
Member

scrthq commented Oct 12, 2018

PSGSuite v2.15.4 now available on the PS Gallery!

Update notes:

2.15.4

  • Issue #96
    • Updated the following on Get-GSGroup:
      • Set default scope to Customer so that getting the list of groups expectedly gets all of them, not just the ones in your primary domain
      • Added Domain parameter to specify which domain to list groups from your customer account
      • Added Filter parameter to only list groups matching the Group query syntax
      • Moved the Get-GSGroupListPrivate private function into the body of Get-GSGroup for error clarity
  • Others:
    • Moved the Get-GSUserListPrivate private function into the body of Get-GSUser for error clarity
    • Improved error handling for User and Message List functions when there are no results.

@efrank85
Copy link

efrank85 commented Dec 15, 2021

@scrthq

I am having a similar issue I cannot get around. I've set my PSGsuiteConfig Preference to "CustomerID" as instructed. However, I am still receiving the below error.

Get-GSGroup : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Bad Request [400]
Errors [
Message[Bad Request] Location[ - ] Reason[badRequest] Domain[global]
]
"
At line:1 char:1

  • Get-GSGroup
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSGroup
    
    

I can run Get-GSGroup against an individual group or CSV import but not the command by itself. I am an SA in GSuite and have literally added every API that has the word "Group" in it trying to troubleshoot. Any help on this issue at all would be much appreciated.

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