taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
687 stars 86 forks source link

[feature request] Add oneitemperrow modifier to gam user x print users license #395

Closed jay-eleven closed 5 months ago

jay-eleven commented 5 months ago

Hi Ross!

I'm trying to list all licenses for a particular user so I do:

gam user user@domain.com print users license

This yields:

primaryEmail,LicensesCount,Licenses,LicensesDisplay
user@domain.com,2,1010330003 1010020025,Google Voice Starter Google Workspace Business Plus

Essentially concatenating all SKU ids and names into Licenses and LicensesDisplay.

Unfortunately, concatenating with a single space instead of a comma (,) makes further processing licenses a bit difficult since this format is not accepted by gam:

<SKUIDList> ::= "<SKUID>(,<SKUID>)*"
[...]
gam <UserTypeEntity> delete|del license <SKUIDList>

<SKUIDList> is a , separated list of <SKUID>s

This means that gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview will not work:

ERROR: Invalid choice (1010330003 1010020025)

I can only think of one way to solve this: add the oneitemperrow modifier like other gam commands already have.

This would make the output look something like this:

gam user user@domain.com print users license oneitemperrow

primaryEmail,LicensesCount,Licenses,LicensesDisplay
user@domain.com,2,1010330003,Google Voice Starter
user@domain.com,2,1010020025,Starter Google Workspace Business Plus

This would allow for reusing that output on a gam csv command for further actions:

gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview actioncsv
License: Google Voice Starter, Delete (Preview) 1 User
  User: user@domain.com, License: 1010330003 (Google Voice Starter), Deleted (Preview)
License: Google Voice Starter, Delete (Preview) 1 User
  User: user@domain.com, License: 1010330003 (Google Voice Starter), Deleted (Preview)

Or maybe there's a simpler way to delete all licenses for a specific user that I overlooked?

Thoughts? 😅

taers232c commented 5 months ago

Jay,

Try this: gam user @.*** print users license delimiter ","

Ross

On Wed, Jan 17, 2024 at 8:53 AM Jay @.***> wrote:

Hi Ross!

I'm trying to list all licenses for a particular user so I do:

gam user @.*** print users license

This yields:

@.***,2,1010330003 1010020025,Google Voice Starter Google Workspace Business Plus

Essentially concatenating all SKU ids and names into Licenses and LicensesDisplay.

Unfortunately, concatenating with a single space instead of a comma (,) makes further processing licenses a bit difficult since this format is not accepted by gam:

::= "(,)*" [...] gam delete|del license is a , separated list of s This means that gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview will not work: ERROR: Invalid choice (1010330003 1010020025) I can only think of one way to solve this: add the oneitemperrow modifier like other gam commands already have . This would make the output look something like this: gam user ***@***.*** print users license oneitemperrow ***@***.***,2,1010330003,Google Voice ***@***.***,2,1010020025,Starter Google Workspace Business Plus This would allow for reusing that output on a gam csv command for further actions: gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview actioncsv License: Google Voice Starter, Delete (Preview) 1 User User: ***@***.***, License: 1010330003 (Google Voice Starter), Deleted (Preview) License: Google Voice Starter, Delete (Preview) 1 User User: ***@***.***, License: 1010330003 (Google Voice Starter), Deleted (Preview) Or maybe there's a simpler way to delete all licenses for a specific user that I overlooked? Thoughts? 😅 — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>

-- Ross Scroggs @.***

taers232c commented 5 months ago

Jay,

I'm doing onelicenseperrow.

Ross

Ross Scroggs @.***

On Jan 17, 2024, at 8:53 AM, Jay @.***> wrote:

Hi Ross!

I'm trying to list all licenses for a particular user so I do:

gam user @.*** print users license

This yields:

primaryEmail,LicensesCount,Licenses,LicensesDisplay @.***,2,1010330003 1010020025,Google Voice Starter Google Workspace Business Plus Essentially concatenating all SKU ids and names into Licenses and LicensesDisplay.

Unfortunately, concatenating with a single space instead of a comma (,) makes further processing licenses a bit difficult since this format is not accepted by gam:

::= "(,)*" [...] gam delete|del license is a , separated list of s This means that gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview will not work: ERROR: Invalid choice (1010330003 1010020025) I can only think of one way to solve this: add the oneitemperrow modifier like other gam commands already have . This would make the output look something like this: gam user ***@***.*** print users license oneitemperrow primaryEmail,LicensesCount,Licenses,LicensesDisplay ***@***.***,2,1010330003,Google Voice Starter ***@***.***,2,1010020025,Starter Google Workspace Business Plus This would allow for reusing that output on a gam csv command for further actions: gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview actioncsv License: Google Voice Starter, Delete (Preview) 1 User User: ***@***.***, License: 1010330003 (Google Voice Starter), Deleted (Preview) License: Google Voice Starter, Delete (Preview) 1 User User: ***@***.***, License: 1010330003 (Google Voice Starter), Deleted (Preview) Or maybe there's a simpler way to delete all licenses for a specific user that I overlooked? Thoughts? 😅 — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.
taers232c commented 5 months ago

Jay,

6.67.20 now supports onelicenseperrow wth print users

Ross

Ross Scroggs @.***

On Jan 17, 2024, at 8:53 AM, Jay @.***> wrote:

Hi Ross!

I'm trying to list all licenses for a particular user so I do:

gam user @.*** print users license

This yields:

primaryEmail,LicensesCount,Licenses,LicensesDisplay @.***,2,1010330003 1010020025,Google Voice Starter Google Workspace Business Plus Essentially concatenating all SKU ids and names into Licenses and LicensesDisplay.

Unfortunately, concatenating with a single space instead of a comma (,) makes further processing licenses a bit difficult since this format is not accepted by gam:

::= "(,)*" [...] gam delete|del license is a , separated list of s This means that gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview will not work: ERROR: Invalid choice (1010330003 1010020025) I can only think of one way to solve this: add the oneitemperrow modifier like other gam commands already have . This would make the output look something like this: gam user ***@***.*** print users license oneitemperrow primaryEmail,LicensesCount,Licenses,LicensesDisplay ***@***.***,2,1010330003,Google Voice Starter ***@***.***,2,1010020025,Starter Google Workspace Business Plus This would allow for reusing that output on a gam csv command for further actions: gam csv licenses.txt gam user ~primaryEmail delete license ~Licenses preview actioncsv License: Google Voice Starter, Delete (Preview) 1 User User: ***@***.***, License: 1010330003 (Google Voice Starter), Deleted (Preview) License: Google Voice Starter, Delete (Preview) 1 User User: ***@***.***, License: 1010330003 (Google Voice Starter), Deleted (Preview) Or maybe there's a simpler way to delete all licenses for a specific user that I overlooked? Thoughts? 😅 — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.
jay-eleven commented 5 months ago

Ooooohhhhhhhh.... this is so embarrasing!!! 🤦

I totally overlooked the [delimiter <Character>] portion of the documentation

I'm sorry! 😅

Tested the new version, works like a charm, as always. 😉

GAM upgrade complete!

Old version: 6.66.12
New version: 6.67.20
jay@cloudshell:~$ gam user user@domain.com print users license onelicenseperrow
Got 0 Licenses for 101001 (Cloud Identity Free)...
[...]
Got 0 Licenses for Google-Vault (Google Vault)...
primaryEmail,License,LicenseDisplay
user@domain.com,1010330003,Google Voice Starter
user@domain.com,1010020025,Google Workspace Business Plus
jay@cloudshell:~$ 

Thanks Ross!