Updating sendas signatures with CSV and template

265 views
Skip to first unread message

Ashley Attwood

unread,
Jul 6, 2018, 8:24:28 AM7/6/18
to GAM for G Suite
I've got GAM updating signatures autonomously by retrieving user information to CSV then writing the signatures from a HTML template file with variables being replaced. I've got different OUs with different signature templates.

Retrieving the directory information:
gam print users query "orgUnitPath='/Aztec'" fields primaryEmail,name,phones,organizations > "Users.csv"

Writing the signatures:
gam csv "Users.csv" gam user ~primaryEmail signature file "Template.txt" replace Name ~name.fullName replace Title ~organizations.0.title replace OfficePhone ~phones.2.value replace Email ~primaryEmail

This only updates the users primary signature and not any sendas signatures.

Can I tweak my 2nd command so that all their signatures are updated with the same template?

The bells and whistles would be if I could retrieve each sendas address into my CSV along with the directory fields. Then write out a custom signature to each where I would edit my "replace Email" function to use the sendas email rather than primaryEmail. I can read a single users sendas into a CSV and I can do all users but I can't get it to combine properly with either the "orgunitpath" filter or the "fields" search.


Has anyone achieved this or similar?

Ross Scroggs

unread,
Jul 6, 2018, 11:01:49 AM7/6/18
to google-ap...@googlegroups.com
Ashley,

You'll need the script (MergeSendasUsers.py), Python2: https://github.com/taers232c/GAM-Scripts, Python3: https://github.com/taers232c/GAM-Scripts3

Start with the Users.csv that you already have.
Produce a Sendas.csv file, e.g., gam ou /Aztec print sendas > Sendas.csv
Merge Sendas.csv with Users.csv into UpdatedUsers.csv: python MergeSendasUsers.py ./Sendas.csv ./Users.csv ./UpdatedUsers.csv
Update all signatures:
gam csv "UpdatedUsers.csv" gam user ~primaryEmail update sendas ~sendAsEmail file "Template.txt" replace Name ~name.fullName replace Title ~organizations.0.title replace OfficePhone ~phones.2.value replace Email~primaryEmail

Ross



This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/b5aef57a-52f0-493a-92bb-edef4ee21a77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Ashley Attwood

unread,
Jul 6, 2018, 11:04:50 AM7/6/18
to GAM for G Suite
Thanks Ross. I'll have a play


On Friday, 6 July 2018 16:01:49 UTC+1, Ross Scroggs wrote:
Ashley,

You'll need the script (MergeSendasUsers.py), Python2: https://github.com/taers232c/GAM-Scripts, Python3: https://github.com/taers232c/GAM-Scripts3

Start with the Users.csv that you already have.
Produce a Sendas.csv file, e.g., gam ou /Aztec print sendas > Sendas.csv
Merge Sendas.csv with Users.csv into UpdatedUsers.csv: python MergeSendasUsers.py ./Sendas.csv ./Users.csv ./UpdatedUsers.csv
Update all signatures:
gam csv "UpdatedUsers.csv" gam user ~primaryEmail update sendas ~sendAsEmail file "Template.txt" replace Name ~name.fullName replace Title ~organizations.0.title replace OfficePhone ~phones.2.value replace Email~primaryEmail

Ross

On Fri, Jul 6, 2018 at 5:24 AM Ashley Attwood <ashley....@aztecuk.com> wrote:
I've got GAM updating signatures autonomously by retrieving user information to CSV then writing the signatures from a HTML template file with variables being replaced. I've got different OUs with different signature templates.

Retrieving the directory information:
gam print users query "orgUnitPath='/Aztec'" fields primaryEmail,name,phones,organizations > "Users.csv"

Writing the signatures:
gam csv "Users.csv" gam user ~primaryEmail signature file "Template.txt" replace Name ~name.fullName replace Title ~organizations.0.title replace OfficePhone ~phones.2.value replace Email ~primaryEmail

This only updates the users primary signature and not any sendas signatures.

Can I tweak my 2nd command so that all their signatures are updated with the same template?

The bells and whistles would be if I could retrieve each sendas address into my CSV along with the directory fields. Then write out a custom signature to each where I would edit my "replace Email" function to use the sendas email rather than primaryEmail. I can read a single users sendas into a CSV and I can do all users but I can't get it to combine properly with either the "orgunitpath" filter or the "fields" search.


Has anyone achieved this or similar?






This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--

Ashley Attwood

unread,
Jul 9, 2018, 7:28:21 AM7/9/18
to GAM for G Suite
I've completed the merge and run the final command:

gam csv "UpdatedUsers.csv" gam user ~primaryEmail update sendas ~sendAsEmail file "Template.txt" replace Name ~name.fullName replace Title ~organizations.0.title replace OfficePhone ~phones.2.value replace Email~primaryEmail

but I get:

ERROR: file is not a valid argument for "Gam <users> update sendas"

Is there a slighting different syntax for pulling a HTML template from a file in the context of sendas?

Ross Scroggs

unread,
Jul 9, 2018, 8:43:45 AM7/9/18
to google-ap...@googlegroups.com
Ashley,

My mistake, I dropped a keyword; the option signature should appear before the option file.

gam csv "UpdatedUsers.csv" gam user ~primaryEmail update sendas ~sendAsEmail signature file "Template.txt" replace Name ~name.fullName replace Title ~organizations.0.title replace OfficePhone ~phones.2.value replace Email~primaryEmail


Ross

This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Ashley Attwood

unread,
Jul 9, 2018, 9:05:39 AM7/9/18
to GAM for G Suite
ahh damn. I should have tried that!! Thanks, that nailed it.
Reply all
Reply to author
Forward
0 new messages