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

Support for Multi-Valued Custom Schema Fields #202

Closed Ephesoft-Stitus closed 5 years ago

Ephesoft-Stitus commented 5 years ago

This module is awesome, however, it doesn't seem currently possible to update a multi-valued custom schema field.

When I attempt to pass in a test I can error like this: PS G:\My Drive\scripts> Update-GSUser -User $email -CustomSchemas @{SSO=@{role='test'}}

Update-GSUser : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError Invalid Input: custom_schema [400] Errors [ Message[Invalid Input: custom_schema] Location[ - ] Reason[invalid] Domain[global] ] " At line:1 char:1

Ideally, a multi-valued field could be set by something like this (or something similar): PS G:\My Drive\scripts> Update-GSUser -User $email -CustomSchemas @{SSO=@{role=@('value1', 'value2')}}

Here's a link to the API doc for custom schemas showing multi line value input: https://developers.google.com/admin-sdk/directory/v1/guides/manage-schemas

Ephesoft-Stitus commented 5 years ago

Turns out you can do it like this: Update-GSUser -User $email -CustomSchemas @{ SSO = @{ role = @(@{type = 'work'; value = 'test'}, @{type = 'work'; value = 'test2'})}}

Hope this helps anybody else who is struggling with this.

scrthq commented 5 years ago

Beat me to the punch, @Ephesoft-Stitus !!! Thanks for replying back with the fix and closing this out!! I'm glad you dig PSGSuite! 💓