Variables in signature file

1,959 views
Skip to first unread message

Steve Main

unread,
Jun 23, 2016, 12:56:07 PM6/23/16
to Google Apps Manager
I was wondering if i can use GAM to have a signature.txt file and have user variables in that file IE

#First Name# #Last Name#
#Title#
#phone#


Or even if there was a way to pull this information from AD first and create #user#.txt that have this information already pre filled in and jsut update each users indavidually

Thanks in advance


Luca Benelli

unread,
Jun 27, 2016, 5:17:13 AM6/27/16
to Google Apps Manager
You can export your AD info to a CSV and then use GAM with a CSV source: https://github.com/jay0lee/GAM/wiki/BulkOperations#using-csv-files

Steve Main

unread,
Jun 27, 2016, 11:49:03 AM6/27/16
to Google Apps Manager

So what i did was run a PowerShell script to get all my users from AD and then have a template and replace values with the AD values and output them as us...@domain.com.html  it works great but for some reason i cannot get the #user# variable to work in my GAM command

gam.exe all users signature file ".\Signatures\#user#.html" 

I used this same kind of command in updating all my AD pictures all the files were named em...@domain.com.jpg and just ran  "gam.exe all users update photo .\ADPictures\#user#.jpg"  is #user# only available when uploading photos but not available in uploading signatures?

I keep gettign this error:
Got 89 users...
done getting 88 users.

ERROR: [Errno 2] No such file or directory: u'C:\\GAM\\Signatures\\Templated Signatures\\#user#.htm'

if i cannot use this method then I will flip to the CSV model you suggested which is mostly the same just a different way round it!

 

Steve Main

unread,
Jun 27, 2016, 11:57:51 AM6/27/16
to Google Apps Manager
gam print users | gam user ~primaryEmail signature file "C:\GAM\Signatures\Templated Signatures\~primaryEmail"


I even tried this with the same error jstu not sure what I am doing wrong here... 

Steve Main

unread,
Jun 27, 2016, 12:36:15 PM6/27/16
to Google Apps Manager
You know what? I just added the GAM command to my PS1 script so it just executes a single user signature update with their file. Ill post my script as soon as it it polished for other users to use!!

Steve Main

unread,
Jun 28, 2016, 1:43:26 PM6/28/16
to Google Apps Manager
Here is the script i wrote myself and I hope other Admins enjoy it!!

https://groups.google.com/forum/#!topic/google-apps-manager/sVDyygYEg7Y


Ross Scroggs

unread,
Jun 28, 2016, 11:55:22 PM6/28/16
to google-ap...@googlegroups.com
Steve,

I've added an update to GAM that will help others in your situation.

Here's a file named SigData.csv:
User,Name,Title
test...@domain.com,Test 1,Number One
test...@domain.com,Test 2,Number Two

Here's a file named SigTemplate.txt:
#Name# - #Title#
#Email#
#Company#
Disclaimer Text

Here's the gam command line:
gam csv SigData.csv gam user "~User" signature file SigTemplate.txt replace "#Email#" "~User" replace "#Name#" "~Name" replace "#Title#" "~Title" -replace "#Company#" "Our Company Name"

I've added a new argument, replace, to gam signature and gam vacation: replace <Pattern> <ReplacementText>
<Pattern> is a Python Regular Expression, but typically it will be a unique text string as in the example.
<ReplacementText> is whatever you want, but typically it will come from a CSV file.
<Pattern> should not be of the form ~Text or ~~Text~~ as GAM will try to make substitutions on the command line.
Note that the text in <Pattern> and the CSV column names do not have to be the same.
<ReplacementText> does not have to come from the CSV file, you can user literal text.
In gam vacation, the replacements are made in the message text; the subject text is not affected.

You don't have to use a CSV file, if you need to do a one-off update, do it like this:
gam user test...@domain.com signature file SigTemplate.txt replace "#Email#" "test...@domain.com" replace "#Name#" "Test 3" replace "#Title#" "Number Three" -replace "#Company#" "Our Company Name"

Command syntax:
gam <UserTypeEntity> signature <String>|(file <FileName>) (replace <REPattern> <String>)*
gam <UserTypeEntity> vacation on subject <String> (message <String>)|(file <FileName>) (replace <REPattern> <String>)*
        [contactsonly] [domainonly] [startdate <Date>] [enddate <Date>]

The distribution contains a file named GamCommands.txt which gives a full syntax description.

I've submitted a pull request to Jay, in the meantime you can try it here:

Ross

On Jun 28, 2016, at 10:43 AM, Steve Main <sm...@quarry.com> wrote:

Here is the script i wrote myself and I hope other Admins enjoy it!!

https://groups.google.com/forum/#!topic/google-apps-manager/sVDyygYEg7Y



--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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/4d72b2cc-907a-41b4-a918-192846238805%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Main

unread,
Jun 29, 2016, 4:34:12 PM6/29/16
to Google Apps Manager
This is awesome and a great addition to GAM. My script that I built is a little more intense and allows for some customization but this is perfect for simple signatures which most peoples will be simple.

Thanks for this addition Ross!! 

Ross Scroggs

unread,
Jun 29, 2016, 4:52:56 PM6/29/16
to google-ap...@googlegroups.com
Steve,

Your script could optionally just produce a CSV file with columns from AD for the user and then invoke GAM as in my examples.

Ross

On Wed, Jun 29, 2016 at 1:34 PM, Steve Main <sm...@quarry.com> wrote:
This is awesome and a great addition to GAM. My script that I built is a little more intense and allows for some customization but this is perfect for simple signatures which most peoples will be simple.

Thanks for this addition Ross!! 

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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.

For more options, visit https://groups.google.com/d/optout.



--

Steve Main

unread,
Jun 29, 2016, 5:04:18 PM6/29/16
to Google Apps Manager
Yes that is correct but I have added the ability to use {RT}   {/RT} tags so that if the field is blank remove everything in between the these tags. so for instance if a template has html  Cell: #Cell#<BR>   If that field is blank then this users signature will have "Cell: <BR>"with no value beside it and then that wrap a line. Using the {RT} tags if #tag# was bank you could remove the whole line IE {RT}Cell: #Cell#<BR>{/RT}  this allows for some more conditional scripting in your template file. If you can add that to GAM.exe that woudl rock as almost all email signature templating programs have this feature that I have used, Acronis, CodeTwo etc..

I will also be adding in the future the ability for it to look for a signature template with the users email address on it son instead of using the default signature template it will read in this one for the user. This would allow for those one off users that need a special template for them. As well the ability to have rotating images and multi templates to rotate through. I'm just at version 1 right now :) I want this script to be the best signature template system out there :) using GAM of course!!

Ross Scroggs

unread,
Jun 29, 2016, 10:22:36 PM6/29/16
to google-ap...@googlegroups.com
Steve,

I'll look into the {RT} stuff.

Your could do the following:
gam csv SigData.csv gam user "~User" signature file "~Template" replace "#Email#" "~User" replace "#Name#" "~Name" replace "#Title#" "~Title" -replace "#Company#" "Our Company Name"

Have the template file name come out of the CSV file.

Ross

On Jun 29, 2016, at 2:04 PM, Steve Main <sm...@quarry.com> wrote:

Yes that is correct but I have added the ability to use {RT}   {/RT} tags so that if the field is blank remove everything in between the these tags. so for instance if a template has html  Cell: #Cell#<BR>   If that field is blank then this users signature will have "Cell: <BR>"with no value beside it and then that wrap a line. Using the {RT} tags if #tag# was bank you could remove the whole line IE {RT}Cell: #Cell#<BR>{/RT}  this allows for some more conditional scripting in your template file. If you can add that to GAM.exe that woudl rock as almost all email signature templating programs have this feature that I have used, Acronis, CodeTwo etc..

I will also be adding in the future the ability for it to look for a signature template with the users email address on it son instead of using the default signature template it will read in this one for the user. This would allow for those one off users that need a special template for them. As well the ability to have rotating images and multi templates to rotate through. I'm just at version 1 right now :) I want this script to be the best signature template system out there :) using GAM of course!!

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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.

Ross Scroggs

unread,
Jun 30, 2016, 2:27:55 AM6/30/16
to google-ap...@googlegroups.com
On Jun 29, 2016, at 2:04 PM, Steve Main <sm...@quarry.com> wrote:

Yes that is correct but I have added the ability to use {RT}   {/RT} tags so that if the field is blank remove everything in between the these tags. so for instance if a template has html  Cell: #Cell#<BR>   If that field is blank then this users signature will have "Cell: <BR>"with no value beside it and then that wrap a line. Using the {RT} tags if #tag# was bank you could remove the whole line IE {RT}Cell: #Cell#<BR>{/RT}  this allows for some more conditional scripting in your template file. If you can add that to GAM.exe that woudl rock as almost all email signature templating programs have this feature that I have used, Acronis, CodeTwo etc..

I will also be adding in the future the ability for it to look for a signature template with the users email address on it son instead of using the default signature template it will read in this one for the user. This would allow for those one off users that need a special template for them. As well the ability to have rotating images and multi templates to rotate through. I'm just at version 1 right now :) I want this script to be the best signature template system out there :) using GAM of course!!

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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.

Steve Main

unread,
Jun 30, 2016, 8:58:33 AM6/30/16
to google-ap...@googlegroups.com

Wow this is amazing!!!

 

I can’t believe you did it this quick. I spent 2 days scripting my PowerShell script J. You Rock Ross way to be on top of stuff!

 

If I can suggest one thing though. If you pull all users down from Google not all users have gmail enabled and you will get an error if you try to set a signature for someone that does not have a gmail account. So if you are doing a batch of users it will error out and stop on that one user that’s an admin user that does not have email enabled. Is there a way to get GAM to only pull down users when using the signature switch that have gmail enabled on their account? Or is there already something up there?

 

I’m going to rewrite my script now to include your new templating system and pulling values from AD J this will be much faster running one GAM command then a single command for every user

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Manager" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/8mJEokp6E2E/unsubscribe.
To unsubscribe from this group and all its topics, 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.


For more options, visit https://groups.google.com/d/optout.



Steve Main

PC Support Specialist 

519.664.2777 ext. 2263 OFFICE  |  877.723.2999 TOLL FREE  |  519.241.8951 MOBILE

WATERLOO  |  RALEIGH-DURHAM  |  SAN JOSE

BRANDING INTO BUYING  |  QUARRY.COM

 

 

 

 

This e-mail message (including any attachments) is intended only for the use of the individual to whom it is addressed and may contain information that is privileged, proprietary, confidential or subject to copyright. If you are not the intended recipient, you are notified that any use, dissemination, distribution or reproduction of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and delete this e-mail message immediately.

Andrus Rähni

unread,
Jan 5, 2017, 5:19:26 AM1/5/17
to GAM for G Suite
Hi.

I have latest GAM version v4.03
Python 2.7.12 64-bit

i'm having problem with setting a signature with this command
gam user user@domain.com signature "#Name# - #Jobtitle#" replace "#Name#" "Users Name" replace "#Jobtitle#" "Users jobtitle"

Result is 
#Name# - #Jobtitle#

What am I doing wrong?

Andrus Rähni

unread,
Jan 5, 2017, 8:43:24 AM1/5/17
to GAM for G Suite
This replace argument doesn't seem to work.

Ross Scroggs

unread,
Jan 5, 2017, 9:17:38 AM1/5/17
to google-ap...@googlegroups.com
Andrus,

Every instance of {Tag} in the signature will be replaced by <String>. Instances of the form {RT}...{Tag}...{/RT} will be eliminated
if there was no <Tag> specified that matches Tag or if a <Tag> matching Tag was specified but the matching <String> is empty.
This is especially useful with CSV files. If you have a CSV file Users.csv with three columns: User,Name,Jobtitle
gam csv Users.csv gam user '~User' signature '{Name} - {Jobtitle}' replace 'Name' '~Name' replace 'Jobtitle' '~Jobtitle'
The column names match the field names in this example but that is not a requirement but does make it easy to see what's going on.
In the template, field names are enclosed in {}.

gam user user@domain.com signature "{#Name#} - {#Jobtitle#}" replace "#Name#" "Users Name" replace "#Jobtitle#" "Users jobtitle"


--
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.

Andrus Rähni

unread,
Jan 5, 2017, 9:46:52 AM1/5/17
to GAM for G Suite
Cool! Very nice! Thank you so much!

I suggest to write this example to the GAM documentation. 
It is quite valuable knowledge :)

Happy new year!
Andrus,

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Robert Robinson

unread,
Jan 20, 2017, 7:37:36 AM1/20/17
to GAM for G Suite
Do I have to use python to run this command?
Andrus,

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Ross Scroggs

unread,
Jan 20, 2017, 9:50:01 AM1/20/17
to google-ap...@googlegroups.com
Robert,

This is a Gam command, no other Python scripts are involved.

The Stephen Perse Pre-Prep, Stephen Perse Foundation Junior School, Stephen Perse Foundation Senior School, The Stephen Perse Sixth Form College and Dame Bradbury's School are the schools of the Stephen Perse Foundation. The Stephen Perse Foundation is a Registered Charity (No:1120608) and a Company limited by guarantee, registered in England and Wales (No:6113565). Its registered office is 19 Union Road, Cambridge, Cambridgeshire CB2 1HF.

This e-mail and any attached file is intended only for the use of the addressee(s) named above and is confidential and may be legally privileged. If you have received this email and are not a named addressee please delete it; you must not disclose, copy, distribute or use the contents in any way that may be unlawful. Although the Stephen Perse Foundation operates anti-virus programmes, it does not accept responsibility for any loss or damage whatsoever that arises from the use of the email or attachments. In addition the Stephen Perse Foundation cannot be held liable for incomplete or corrupted transmissions, delay in receipt or any errors or omissions in the content of the email, as a result of transmission. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Foundation.

--
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.

Robert Robinson

unread,
Jan 23, 2017, 4:52:00 AM1/23/17
to GAM for G Suite
Hmm, that's what I thought. I've tried running the command but the replace command isn't working. I'm getting the same issue as Andrus was getting where the signature will come through with #Name #Title etc.

Robert Robinson

unread,
Jan 23, 2017, 7:39:28 AM1/23/17
to GAM for G Suite
This is the command I have: gam csv SigData.csv gam user "~User" signature file "~Template" replace "{Name}" "~Name" replace "{Title}" "~Title" replace "{Department}" "~Department"

In the SigTemplate.txt I have {RT} {Name} {/RT} where I want the name to change. I have done the same for the other fields.

Ross Scroggs

unread,
Jan 23, 2017, 8:59:01 AM1/23/17
to google-ap...@googlegroups.com
Robert,

You want: gam csv SigData.csv gam user "~User" signature file "~Template" replace "Name" "~Name" replace "Title" "~Title" replace "Department" "~Department"

The {} are used in the template, not in the command line tags.

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.

Robert Robinson

unread,
Jan 23, 2017, 9:08:17 AM1/23/17
to GAM for G Suite
Many thanks! This works. I tried all sorts of combinations but not this one.

Reply all
Reply to author
Forward
0 new messages