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

Add "Create New Default Routing Rule" #171

Closed derekritchison closed 5 years ago

derekritchison commented 5 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

derekritchison commented 5 years ago

When we terminate a former employee we temporarily create a default routing rule that "changes the envelope recipient" from the former employee to their manager. Would be nice if I could automate this with PowerShell.

scrthq commented 5 years ago

hey @derekritchison - I want to say that this isn't doable via API currently, but I'll confirm! If you happen to have a link to any of Google's API documentation that handles this already, that would help me expedite this =]

scrthq commented 5 years ago

The Admin Settings API may do it, but it's also been flagged for deprecation and I'm not aware of a replacement for it yet

derekritchison commented 5 years ago

Thanks for the incredibly quick response. Gonna read up on that API even though it's deprecated, because I'm kinda curious.

scrthq commented 5 years ago

Other links: https://gsuiteupdates.googleblog.com/2017/10/shutdown-of-gdata-admin-settings-api.html

https://gsuiteupdates.googleblog.com/2018/10/gdata-admin-settings-api-shutdown-update.html

Note from that last one:

image

scrthq commented 5 years ago

I'll work on adding support for the current API since your desired endpoint is still up until they have a replacement for it, at which time I'll work in the replacement similar to what I did for the Gmail Inbox Delegation endpoints once they were rolled into the Gmail API

derekritchison commented 5 years ago

This is what we currently configure, manually, on Google Admin.

routing
scrthq commented 5 years ago

Gotcha! So, I want to say that setting up compliance rules like that are not manageable from API calls. The Admin Settings API would be able to manage your overall email route / gateway, but not those types of rules as far as I'm aware.

scrthq commented 5 years ago

Yeah, pretty positive that any settings at that level are not configurable via API. What about adding in a filter to forward to the replacement recipient instead? I know it's not as direct as setting up a compliance rule as noted, but that would absolutely be configurable via existing commands in PSGSuite if desired.

derekritchison commented 5 years ago

I believe that would require the former employee's inbox to remain active.

scrthq commented 5 years ago

It would indeed, unfortunately. At least the Gmail service. With your offboarding process, are you completely deleting the user, flipping them over to a Vault license, or something else?

derekritchison commented 5 years ago

Completely deleting, after doing a full .mbox export.

scrthq commented 5 years ago

@derekritchison - Got it! Alright, yeah, I believe I'm a little stuck here then based on lack of public API from Google's side for that specific functionality.

Were you interested in any of the remaining Admin Settings API functionality being added? I will get them added as-is if desired, otherwise I'm going to close this out and revisit once Google adds the functionality to the Admin SDK

derekritchison commented 5 years ago

Understood! Would definitely be a nice feature when it's available as it would streamline our offboarding process even more. Feel free to close the thread!

That said, maybe this is off topic but I'm curious about the "Add-GSGmailFilter" command. What I'm trying to do is create a filter based on one criteria --- if a certain e-mail address appears in the "To" field. Far as I understand the command should look like this:

Add-GSGmailFilter -User -To <another user's address> -AddLabelIDs <whatever label I'm using for this filter>

Am I missing something, or just misunderstanding the purpose of this command entirely?

scrthq commented 5 years ago

No worries, that should be accurate! Are you getting an error or unexpected behavior or....?

scrthq commented 5 years ago

Worth noting that if it's a non-standard LabelID (basically any label that you created yourself), you will need to pull the actual label ID first using Get-GSGmailLabel. Self-created labels will typically have an ID that looks like Label_#, i.e. Label_21

derekritchison commented 5 years ago

I see, so if I create a label for another user by running...

New-GSGmailLabel -User user@domain.com -Name

...I then have to somehow grab the unique "LabelID" before running my next step, which would be setting up that new filter?

scrthq commented 5 years ago

It'll return the newly created label, so if you capture that in a variable, you can easily access the ID without querying the label list again:

image

You'll get a conflict if the label name already exists:

image

scrthq commented 5 years ago

This is the error you'll see if the label ID you're trying to access doesn't exist:

image

Compared to a successful run where we use the actual labelID:

image

derekritchison commented 5 years ago

Great. Thanks! Been very helpful!

scrthq commented 5 years ago

Happy to hear!! Let me know if you have any other questions!! Cheers!