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

[Feedback] What additional Google API's would YOU like to see added to PSGSuite? #16

Closed scrthq closed 6 years ago

scrthq commented 6 years ago

PSGSuite was originally created for personal and work-related automation, so functions were created somewhat sporadically without 100% coverage of each API in scope. For most, the functions available should cover what's needed, but I'd like to increase the coverage as much as possible!

Please leave a comment with any Google APIs/endpoints* you would like to see added into PSGSuite! If you have a link to Google's documentation page for that API, that would be appreciated as well to remove any possible confusion.

*At the moment, this is going to be somewhat limited to APIs outside of Google Cloud Platform, but if the demand is there, I'm open to digging into GCP API's like Vision API and the like.

Looking forward!


Progress Checklist

Waffle.io - Columns and their card count

ryanfog commented 6 years ago

How about IMAP settings to see what users are enabled? In addition, what OU's have IMAP disabled.

scrthq commented 6 years ago

@ryanfog - Getting the OU level settings for services like Gmail isn't possible at the moment via API that I'm aware of (please send any API links you have otherwise so I can check them out, it would be awesome if doable!), but pulling individual users' Gmail settings is definitely doable ๐Ÿ‘

scrthq commented 6 years ago

@ryanfog - IMAP, POP, AutoForwarding and Vacation settings all added in v2.2.0! Included functions to both Get settings and Update settings for all.

ryanfog commented 6 years ago

Nate are you in active development on this module? I prefer your module over GAM since the output is an actual PowerShell object that I can then do other things with compared to GAM's massive string output. If you are active on this module I would like to submit additional functionality and be willing to test out those functions to fully remove GAM for my ongoing management of GSuite.

scrthq commented 6 years ago

@ryanfog yup!I took a break from this module for a while, but have been pretty active with it again since starting work on v2.0.0+. You can check the code-frequency graph to see activity. I'll work on getting an official contributing guide written up! All help is appreciated, I'd love to see full Google API coverage (at least for G Suite related API's) at some point if possible! Wanting a better experience in PowerShell than GAM provides was my initial motivation for writing this module in the first place, I totally get your pains with GAM + PowerShell!

ryanfog commented 6 years ago

Quick question being a former Exchange admin now managing Google. We have the option to create contacts in Exchange. Does Google have that ability to create contacts in the Global Directory? If so can you add this feature?

scrthq commented 6 years ago

@ryanfog I want to say yes (I know it does for individual users). Checking it out!

scrthq commented 6 years ago

@ryanfog alright, so the Contacts API is part of the Google Data API's, which are all either deprecated or the libraries are no longer maintained. The GData .NET library hasn't been updated in almost 5 years and doesn't use the same auth Service mechanisms that their current API's (and PSGSuite) use, so it's going to take a bit of work to get working if even possible.

There is also the Domain Shared Contacts API, but that's also part of the GData API structure from what I can tell with no available assembly to load in.

I will see what I can do about possibly going the route that I took for PSGSuite v1.x.x using the Owin libraries to build an auth token and send API calls via Invoke-RestMethod instead. Updates to follow, but it won't be as quick a turnaround as it was for the Gmail Settings.

scrthq commented 6 years ago

@ryanfog Here's a different option already available as a PowerShell module from CData, in case you have something immediate to handle!

https://www.powershellgallery.com/packages/GoogleContactsCmdlets/

jboiselle commented 6 years ago

Hey Nate, would it be possible to get cmdlets to remove or disable email forwarding in Gmail? Update-GSGmailAutoForwardingSettings doesn't appear to let you disable forwarding.

scrthq commented 6 years ago

@jboiselle hey Josh! The parameters for the functions in PSGSuite are typically matched to the Body object parameters the SDK expects (Body object being an AutoForwardingSettings object in this case). Because of this, the parameters may not be quite as expected, but worth keeping in mind that switch parameters like the -Enabled parameter on Update-GSGmailAutoForwardingSettings can be negated by flagging as $false. Here is how you would disable auto-forwarding with PSGSuite, let me know if you have any issues with it!

Update-GSGmailAutoForwardingSettings -Enabled:$false
scrthq commented 6 years ago

@jboiselle - FYI, found an issue with the scope in use for that specific function (https://github.com/scrthq/PSGSuite/issues/25). Fix is complete and tested and being deployed to PowerShell Gallery as v2.2.1 as we speak though!

scrthq commented 6 years ago

@jboiselle fixed in v2.2.1!

Example of setting and disabling autoforwarding:

image

ryanfog commented 6 years ago

I have another request, I would like a way to subscribe a user to a calendar resource.

The GAM version appears to be this. GAM User $($user.UserMailbox) Add Calendar $($user.CalendarEmail) Selected true

Thanks,

scrthq commented 6 years ago

@ryanfog you got it! Adding calendars is a no brainer, I'm on it!

ryanfog commented 6 years ago

I am sure you are getting sick of my requests but what about adding an Alias into Google. Does that exist already and I was unable to find it?

scrthq commented 6 years ago

@ryanfog haha no worries at all, that's why I have this post up!

User and group aliases are both doable. Adding them to the list!

FYI - I'm in the process of prepping for a move right now, so my availability is a little slimmer than usual! Apologies for any delays in additional functionality! Pull requests are always accepted if you're feeling adventurous!

scrthq commented 6 years ago

@ryanfog - CalendarSubscription, Group Alias and User Alias management functions added in v2.3.0! Update when you can and you should see them there!

Thanks for the suggestions, let me know how they work for you!

jboiselle commented 6 years ago

Hey Nate, what about modifying custom schema attributes on users? As far as I can tell, the tools to create and modify the schemas are already here, but there does not appear to be a way to set/modify custom attributes on individual users (please correct me if I'm wrong). It looks like this is done through the Users 'patch' method in the API?

scrthq commented 6 years ago

@jboiselle I thought I'd had schema updating built-in with Update-GSUser, but checked again and you're right!

The Patch method is being phased out in favor of the Update method (same functionality, but better performance), but the example the Developer docs give does use Patch.

I'll work on adding it into Update-GSUser ASAP! It will likely accept a hashtable as the argument, i.e. something like this (using Google's schema as an example here):

Update-GSUser -User test -Schema @{
    employmentData = @{
        employeeNumber = "123456789"
        jobFamily      = "Engineering"
        location       = "Atlanta"
        jobLevel       = 8
        projects       = @(
            @{ value = "GeneGnome" },
            @{ value = "Panopticon"; type = "work" },
            @{ value = "MegaGene"; type = "custom"; customType = "secret" }
        )
    }
}
ryanfog commented 6 years ago

One of the things I enjoyed with Exchange operations was doing something like Get-Mailbox - ResultSize 25, this would bring me back a random list of 25 mailboxes. If I did something like Get-Mailbox -All I would pull back all mailboxes.

I was thinking I could run something like Get-GSUser and get everyone, but that just brings back myself. There are other commands I would like to do on a global level without doing them per user as well. Does Google have the option to pull all the users in one request, I want to be cautious of hitting any throttle limits.

scrthq commented 6 years ago

@ryanfog - I designed Get-GSUser to have as much parity with Get-ADUser as possible, so if you're looking to pull the user list, just run Get-GSUser -Filter * ๐Ÿ˜„. Get-GSUser does have a PageSize parameter in that parameter set, but the default will still pull all pages. We have about 9000 user objects in our org and it takes just under 1 minute to pull them all for me. Let me know if you feel getting a limited selection of those back is useful and I'll try to work it in as a ResultsSize or MaxResults parameter!

ryanfog commented 6 years ago

Nate,

In my environment which is slightly more users then yours I get this error message.

capture

scrthq commented 6 years ago

I'll check it out as soon as I'm back on a computer tonight! Would you mind opening up a new issue for it so it's tracked outside of this issue/thread?

On Mon, Apr 16, 2018 at 2:06 PM ryanfog notifications@github.com wrote:

Nate,

In my environment which is slightly more users then yours I get this error message.

[image: capture] https://user-images.githubusercontent.com/25650327/38829611-410ce284-417f-11e8-8db1-5652df9d388f.JPG

โ€” You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/scrthq/PSGSuite/issues/16#issuecomment-381715170, or mute the thread https://github.com/notifications/unsubscribe-auth/AMIo3S930ymJTkWmE0xawqPjbC6Ra9Iqks5tpOvGgaJpZM4R-rXM .

-- Thank you for your time, Nate Ferrell (SCRT HQ)

cooper commented 6 years ago

I second interest in adding values for custom user schema!

cooper commented 6 years ago

Also, will it be possible to query users by custom schema? I want to use an employee identifier for account syncing purposes, but I have to use custom schema because it needs to remain private to domain admins.

scrthq commented 6 years ago

@cooper - You can query by custom schema value, just follow the Users Search syntax here: https://developers.google.com/admin-sdk/directory/v1/guides/search-users

Example using PSGSuite to do this with the assumption that you have a schema named "ExtraDetails" and a field in that Schema named "Location" and you are searching for users with 'Sydney' as the location:

Get-GSUser -Filter "ExtraDetails.Location='Sydney'"
NFLEagles1 commented 6 years ago

First of all, thank you Nate for this excellent project. I'm not a developer and don't understand Visual Studio for the life of me. By deconstructing the functions you already have, I've been able to make quite a few additional functions to the Public\Sheets container including creating new Spreadsheet on a team drive in a predefined folder, customize Sheet name(s), format header row and freeze, as well as data validation and conditional formatting. Admittedly I'd have to go through and update the help sections and remove some static entries to parameters, but I'd be glad to submit the functions and have others correct it in a way that conforms to the standards you want.

I tend to use Powershell to connect to various API's (example VMware Airwatch MDM). Using Sheets to post the logs of actions it performs has been extremely helpful.

In looking through the comments, I see interest to integrate GCP. I just wanted to point out that Google Tools for Powershell is out there and created by Google. Frankly I've been disappointed with Google for NOT creating Powershell tools for Gsuite, but your project has been a godsend for myself and am glad to contribute. Just keep in mind I'm playing Jack of all trades, so I don't always have the best understanding of standards and process, but I can often figure something out given enough time.

scrthq commented 6 years ago

@NFLEagles1 - That's awesome to hear! Probably the easiest way to submit your additions would be to send it as a pull request here; that will allow me to review what's there and offer pertinent feedback, then merge those changes into a new release with any adjustments as necessary. I can take care of updating the Wiki once merged (I have a script that regenerates the Help Docs and pushes the updates to the Wiki directly).


Rough Contributing Guide

Style/Code Guidelines

All functions must include the following in order to pass CI tests:

Pull Request How-To

  1. Fork this project into your own account
  2. Clone your fork to your local machine
  3. Add your changes to your machine's cloned repo
  4. Commit the changes with a decent commit message (i.e. 50 chars or less and descriptive at a high level of what's being added/changed)
  5. Push that commit to your GitHub account
  6. Submit a pull request to this repo with your changes.
scrthq commented 6 years ago

@jboiselle & @cooper - Custom User Attribute updating working in dev, just figuring out how to also Clear a value if passing $null, as currently it only updates/patches what's there and passing $null does not do anything (similar to the External ID issue for #33 submitted by @cooper as well). Getting this working should solve for both ๐Ÿ˜ƒ

scrthq commented 6 years ago

@jboiselle & @cooper - Custom User Attribute updating working in dev, also have clearing them working. Here are a couple options, please let me know which you feel would be easier to work with:

Adding a schema value for a user

Schema Name: employementData Schema Fields: employeeNumber & jobFamily

Option 1: Using a hashtable

Update-GSUser -User test -CustomSchemas @{
    employmentData = @{
        employeeNumber = "123456789"
        jobFamily      = "Engineering"
    }
}

Option 2: Using a helper function

# Schema Name: employementData
# Schema Fields: employeeNumber & jobFamily
Update-GSUser -User test -CustomSchemas (Add-GSUserCustomSchema -SchemaName employmentData -Fields @{
        employeeNumber = "123456789"
        jobFamily      = "Engineering"
    })

Clearing schema values for a user

Schema Name: employementData Schema Fields: employeeNumber & jobFamily

Option 1: Using a hashtable

Update-GSUser -User test -CustomSchemas @{
    employmentData = @{
        employeeNumber = $null
        jobFamily      = $null
    }
}

Option 2: Using a helper function

# Schema Name: employementData
# Schema Fields: employeeNumber & jobFamily
Update-GSUser -User test -CustomSchemas (Add-GSUserCustomSchema -SchemaName employmentData -Fields @{
        employeeNumber = $null
        jobFamily      = $null
    })

Thoughts?

jasilbs commented 6 years ago

Hi Nate, I'm not sure if the API allows, but is is possible to set Forwarding via user-level routing in the Admin console, opposed to doing it at the user level settings?

Thanks, Jeremy

scrthq commented 6 years ago

Hey Jeremy @jasilbs - trying to picture what you're looking to do still, but I can say that Admin level settings (i.e. Apps > G Suite > Gmail > Advanced Settings) aren't configurable through API calls at this time. Any insight on where you would make that change using the WebUI would help me confirm that better in case I'm off-mark ๐Ÿ˜ƒ

jboiselle commented 6 years ago

@scrthq I personally wouldn't mind either way. I'm leaning towards helper function since New-GSUserSchema itself already uses a helper function already anyway. As long as it is all documented! :)

jasilbs commented 6 years ago

Hi Nate,

Thanks for the quick reply.

There appear to be a few benefits to using User-Level routing (forwarding), as opposed to doing it from the users auto-forwarding mailbox options.

  1. The admin can configure forwarding, while also preventing the user from having the ability to change it independently. This helps prevent the user screwing something up in the future.
  2. User-Level routing forwards all mail before delivering it to the google mailbox. Setting the user based auto-forwarding only forwards the mail post mailbox delivery. When set via the auto-forward mailbox option, Spam/Junk email is not forwarded. This sounds like a good thing, but can be quite a nuisance in the case of false-positives. With Auto-Forward, users have the ability to find forwarded mail in their Archive or Trash location, depending on how the auto-forward is configured. User-Level routing leaves no trace of the mail in the G Suite Mailbox. Forward messages to a specific recipient
    1. Sign inhttps://admin.google.com/ to your Google Admin consolehttps://support.google.com/a/answer/182076. Sign in using your administrator account (does not end in @gmail.com).
    2. From the Admin console dashboard, go to Users.
    3. In the Users list, find the user. If you need help, see Find a user accounthttps://support.google.com/a/answer/33324.
    4. Click the userโ€™s name to open their account page.
    5. Click User information.
    6. In the Email routing section, click Configure email routing.
    7. Under Email routing, click Add another destination.
    8. In the new row that appears, enter the forwarding email address for the user's messages and press Enter.
    9. Click Save.

Regards,

Jeremy

From: Nate Ferrell notifications@github.com Sent: Monday, April 30, 2018 3:32 PM To: scrthq/PSGSuite PSGSuite@noreply.github.com Cc: jasilbs jeremy-git@silbers.net; Mention mention@noreply.github.com Subject: Re: [scrthq/PSGSuite] [Feedback] What additional Google API's would YOU like to see added to PSGSuite? (#16)

Hey Jeremy @jasilbshttps://github.com/jasilbs - trying to picture what you're looking to do still, but I can say that Admin level settings (i.e. Apps > G Suite > Gmail > Advanced Settings) aren't configurable through API calls at this time. Any insight on where you would make that change using the WebUI would help me confirm that better in case I'm off-mark ๐Ÿ˜ƒ

โ€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/scrthq/PSGSuite/issues/16#issuecomment-385504377, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlEPqLsZFKbUk6cywrcf_TSyc0PYy_pZks5tt2bNgaJpZM4R-rXM.

scrthq commented 6 years ago

Thanks, Jeremy!

I'm not seeing any ability to configure email route through the Directory API where it would expectedly be located. The now-deprecated Admin Settings API used to be able to set that at the Org level, but the assemblies for that have not been updated in years and will not be as it stands without Google developing and releasing a full replacement.

Going to keep looking for email route configuration via the Directory API in case I wasn't seeing it on first look, but everything I'm seeing now indicates it's not doable through API, unfortunately.

scrthq commented 6 years ago

@jboiselle that's my initial thought towards the helper function route (keeping the expectation the same), but in this case it adds a lot of extra typing IMHO, especially considering it would only be abstracting the top level key of the hashtable. The "fields" level hashtable would still be needed and may be less desirable syntactically.

I think for this instance, I'm going to keep it as a pure Hashtable for simplicity (also since that code is ready to push). If there's natural confusion due to the expectation of the helper function, I'll revisit and update it ๐Ÿ˜„

scrthq commented 6 years ago

@jboiselle @cooper - User Schema value management added to Update-GSUser and pushed out in v2.5.0, now available on the PSGallery ๐ŸŒฎ . Update-Module PSGSuite; ipmo PSGSuite -Force to update and import the updated version now! ๐Ÿ˜„

Update-GSUser docs also updated: https://github.com/scrthq/PSGSuite/wiki/Update-GSUser#-customschemas

jasilbs commented 6 years ago

Hi Nate,

Thanks for looking into it for me.

Jeremy

From: Nate Ferrell notifications@github.com Sent: Monday, April 30, 2018 4:07 PM To: scrthq/PSGSuite PSGSuite@noreply.github.com Cc: jasilbs jeremy-git@silbers.net; Mention mention@noreply.github.com Subject: Re: [scrthq/PSGSuite] [Feedback] What additional Google API's would YOU like to see added to PSGSuite? (#16)

Thanks, Jeremy!

I'm not seeing any ability to configure email route through the Directory API where it would expectedly be located. The now-deprecated Admin Settings APIhttps://developers.google.com/admin-sdk/admin-settings/#managing_email_routing_settings used to be able to set that at the Org level, but the assemblies for that have not been updated in years and will not be as it stands without Google developing and releasing a full replacement.

Going to keep looking for email route configuration via the Directory API in case I wasn't seeing it on first look, but everything I'm seeing now indicates it's not doable through API, unfortunately.

โ€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/scrthq/PSGSuite/issues/16#issuecomment-385512997, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlEPqEWveEcmkbBLQPrEs1zjQhN4OyPBks5tt27LgaJpZM4R-rXM.

phatmandrake commented 6 years ago

The API supports a Query/Filter feature for groups. Is it possible to update the functions to account for this?

scrthq commented 6 years ago

@phatmandrake - So, the odd part about that particular API call is there's no apparent Query parameter in the .NET SDK's implementation of Groups.List() like there is on the REST API directly. Without resorting back to making pure REST API calls, the implementation would need to still pull the full list of groups then filter them down by piping to a Where-Object {.....}, which would be better off done within your own pipeline visible on your script, in my honest opinion, that way you retain visibility towards the filtering and full list of objects returned.

> $request.Query = "email:support*"
The property 'Query' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:1
+ $request.Query = "email:support*"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The only similar parameter that the .NET SDK provides on Groups.List() is the UserKey parameter, which can be found as Get-GSGroup -Where_IsAMember user@domain.com (-UserKey will also work though as an alias).


Not sure how many groups you're working with or how long it takes you to pull all of them, but the API acts pretty quick for me even when returning the 1730 groups we have (~4 seconds to pull all of them):

[11] โšก  [PS 5.1.17134.48] โšก  [0:00:00.0259 @ 6:50:44 PM] [master โ‰ก +0 ~1 -0 !]
[C:\GDrive\PSModules\PSGSuite2]
[I โ™ฅ Code]> (Get-GSGroup -Verbose).Count
VERBOSE: Building ServiceAccountCredential from P12Key as user 'natxxxxxxxxxxxxx@xxxx.xxx'
VERBOSE: Getting all G Suite groups for customer 'C00xxxxxxxx'
VERBOSE: Retrieved 200 groups...
VERBOSE: Retrieved 400 groups...
VERBOSE: Retrieved 600 groups...
VERBOSE: Retrieved 800 groups...
VERBOSE: Retrieved 1000 groups...
VERBOSE: Retrieved 1200 groups...
VERBOSE: Retrieved 1400 groups...
VERBOSE: Retrieved 1600 groups...
VERBOSE: Retrieved 1730 groups...
1730
[12] โšก  [PS 5.1.17134.48] โšก  [0:00:04.0389 @ 6:50:57 PM] [master โ‰ก +0 ~1 -0 !]
[C:\GDrive\PSModules\PSGSuite2]
[I โ™ฅ Code]>
megan201296 commented 6 years ago

Pull 2FA enrollment / settings info. Not sure if this is already included in a module and I'm just missing it.

scrthq commented 6 years ago

hey @megan201296 - you can pull 2FA/2SV enrollment/enforcement stats a few different ways, with my most preferred way going pure PowerShell filtering against the full User List

  1. Get the User List
    
    # Filter using Google's syntax
    ### Fastest method
    ### About 99% accurate

PS > $unenrolled = Get-GSUser -Filter "IsEnrolledIn2Sv=false" -Verbose VERBOSE: Building ServiceAccountCredential from P12Key as user 'natxxxxxxxxxxxxxxxx@xxxxxxx.xxx' VERBOSE: Getting Users for customer 'xxxxxxxxxx' matching filter: "IsEnrolledIn2Sv=False" VERBOSE: Retrieved 500 users... VERBOSE: Retrieved 1000 users... VERBOSE: Retrieved 1500 users... VERBOSE: Retrieved 2000 users... VERBOSE: Retrieved 2500 users... VERBOSE: Retrieved 3000 users... VERBOSE: Retrieved 3335 users... PS > ($unenrolled | Where-Object {$_.IsEnrolledIn2Sv}).Count 1

Pull full list of users and filter by piping the results to Where-Object

Can be slower depending on the user count matching your filter vs total user count

100% Accuracy

PS $unenrolled = Get-GSUser -Filter * -Verbose | Where-Object {!$.IsEnrolledIn2Sv} VERBOSE: Building ServiceAccountCredential from P12Key as user 'natxxxxxxxxxxxxxxxx@xxxxxxx.xxx' VERBOSE: Getting all Users for customer 'xxxxxxxxxx' VERBOSE: Retrieved 500 users... VERBOSE: Retrieved 1000 users... VERBOSE: Retrieved 1500 users... VERBOSE: Retrieved 2000 users... VERBOSE: Retrieved 2500 users... VERBOSE: Retrieved 3000 users... VERBOSE: Retrieved 3500 users... VERBOSE: Retrieved 4000 users... VERBOSE: Retrieved 4500 users... VERBOSE: Retrieved 5000 users... VERBOSE: Retrieved 5500 users... VERBOSE: Retrieved 6000 users... VERBOSE: Retrieved 6500 users... VERBOSE: Retrieved 7000 users... VERBOSE: Retrieved 7500 users... VERBOSE: Retrieved 8000 users... VERBOSE: Retrieved 8500 users... VERBOSE: Retrieved 9000 users... VERBOSE: Retrieved 9099 users... PS > ($unenrolled | Where-Object {$.IsEnrolledIn2Sv}).Count 0

2. Get the User Report
```powershell
# Useful if you need a report that includes pure numbers already
### Reports are specified by date
### Some dates don't capture every data point, including 2SV stats
PS > $usage = Get-GSUsageReport -Date (Get-Date).AddDays(-2)
PS > ($usage | Where-Object {$_.Name -like '*2SV*'})

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 3555
MsgValue         :
Name             : accounts:num_users_2sv_enforced
StringValue      :

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 5763
MsgValue         :
Name             : accounts:num_users_2sv_enrolled
StringValue      :

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 3554
MsgValue         :
Name             : accounts:num_users_2sv_enrolled_and_enforced
StringValue      :

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 5528
MsgValue         :
Name             : accounts:num_users_2sv_not_enforced
StringValue      :

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 3320
MsgValue         :
Name             : accounts:num_users_2sv_not_enrolled
StringValue      :

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 3319
MsgValue         :
Name             : accounts:num_users_2sv_not_enrolled_and_not_enforced
StringValue      :

Date             : 2018-05-22
BoolValue        :
DatetimeValueRaw :
DatetimeValue    :
IntValue         : 1
MsgValue         :
Name             : accounts:num_users_2sv_not_enrolled_but_enforced
StringValue      :
nsclarkson commented 6 years ago

Love to see RoleAssignmentsResource so I can grant users admin role.

Thanks!

scrthq commented 6 years ago

@nsclarkson On it!

queks commented 6 years ago

If it were possible, could we get a corresponding set of functions for Google Documents as PSGSuite currently has for Google Sheets? (i.e. clear, copy, export, import, new, get-info)

In addition, is it possible for both sheets and documents to be converted to other file formats, like PDF?

scrthq commented 6 years ago

@queks - There's no Docs specific API like there is for Sheets, unfortunately, so you're limited to Drive File level interaction not file content interaction. This would allow you to do things like getting file metadata (via Get-GSDriveFile -FileId $doc.Id), create new Docs (via New-GSDriveFile -Name 'New Doc' -MimeType Docs), or exporting as a defined MimeType, i.e. PDF (via Export-GSDriveFile -FileID $doc.id -Type PDF -OutFilePath C:\test\doc.pdf). Hopefully that helps clarify!

Please note that there is a current bug with Export-GSDriveFile that should be resolved by tonight/tomorrow. You can track that in issue #51

queks commented 6 years ago

Got it. Thank you.

scrthq commented 6 years ago

@queks - v2.6.3 has been released with the fix for issue #51 (Export-GSDriveFile). Couple other useful pieces of info for you:


Regarding replication of Import-GSSheet for Docs; you can use the following to pull the content of a Doc down in PlainText, effectively pulling down that Doc's text, with the following:

Export-GSDriveFile -FileId $doc.id -Type PlainText

Worth noting that this will always return a single string, so if you need it split to replicate the behavior of Get-Content, you'll need to split it by New Line, i.e.

$docContent = (Export-GSDriveFile -FileId $doc.id -Type PlainText) -split "`n"

I could add a wrapper function designed specifically for this if desired, something along the lines of the following (let me know!):

$docContent = Get-GSDocContent -FileId $doc.id


Also, I should be able to get something going to allow updating of Docs, just trying to figure out how to best approach it in a way that makes sense. Some scenarios here, let me know your feedback on them:

  1. Writing plain text to a doc (i.e. logging, etc).
    • This would be similar to Out-File and would support an -Append switch to attach new strings to the end of the file.
    • This would be limited to PlainText only
    • Proposed function names (let me know which makes most sense):
      • Set-GSDocContent/Add-GSDocContent
      • Out-GSDoc/Out-GSDoc -Append
      • Out-GSDriveFile/Out-GSDriveFile -Append
  2. Pull in an existing file as a byte array and update the file in Drive
    • This would allow updating of any file type, including binary files
    • No option to send strings directly, but not limited to PlainText either
    • This would be literally updating a Drive file's content with a local file's content.
    • Proposed function name:
      • Update-GSDriveFile
queks commented 6 years ago

Thanks Nate, didn't realize i could export a Doc that way.

As for the writing to Docs... I have to admit i'm not quite the expert. I'd say that the first approach (sending strings) makes more sense to me, especially if there are ways to format the text (i.e. by having placeholders - kinda like content controls in docx). But I don't see those in Google Docs...

I still think this way is simpler and more convenient though, as opposed to having to stream a byte array and handle special characters. You would be able to do string manipulation prior to updating the Google doc, so i think its a more flexible of the two options.

On Sat, Jun 9, 2018 at 2:22 PM Nate Ferrell notifications@github.com wrote:

@queks https://github.com/queks - v2.6.3 has been released with the fix for issue #51 https://github.com/scrthq/PSGSuite/issues/51 ( Export-GSDriveFile). Couple other useful pieces of info for you:

Regarding replication of Import-GSSheet for Docs; you can use the following to pull the content of a Doc down in PlainText, effectively pulling down that Doc's text, with the following:

Export-GSDriveFile -FileId $doc.id -Type PlainText

Also, I should be able to get something going to allow updating of Docs, just trying to figure out how to best approach it in a way that makes sense. Some scenarios here, let me know your feedback on them:

  1. Writing plain text to a doc (i.e. logging, etc).
    • This would be similar to Out-File and would support an -Append switch to attach new strings to the end of the file.
    • This would be limited to PlainText only
  2. Pull in an existing file as a byte array and update the file in Drive
    • This would allow updating of any file type, including binary files
    • No option to send strings directly, but not limited to PlainText either
    • This would be literally updating a Drive file's content with a local file's content.

โ€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scrthq/PSGSuite/issues/16#issuecomment-395944189, or mute the thread https://github.com/notifications/unsubscribe-auth/AggCMujffs9cttnWiqDsgKD_3rF7kxywks5t62mQgaJpZM4R-rXM .

--

Samuel QUEK IT Associate Director Taipei American School 800 Chung Shan N. Rd., Section 6 | Taipei | Taiwan ROC 11152 Tel: 886-2-2873-9900 ext 286 www.tas.edu.tw

TAS is Green: Please consider the environment before printing this email.

--

Confidentiality Notice: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.