Find all users with forward on and output user and forwardingaddress set

573 views
Skip to first unread message

Susan McClure

unread,
Jul 7, 2020, 12:13:31 PM7/7/20
to GAM for G Suite
I am not very savvy with GAM and csv files for input and output. 

I am trying to find all (active) users with forward ON and dump to .csv file their user account and the forwardingaddress they have set

Reading through many posts, I have tried several commands without success.  



1)  This says it ran, BUT the output file, ForwardedUsers.csv was empty -  to be fair, it seems to just hang after outputting
'done getting 22149 Users.'  and the Prompt does not return. 

C:\GAMADV-XTD3>gam all users print forward > ForwardedUsers.csv 

Getting all Users in G Suite account (may take some time on a large account)...
Got 22149 Users...
done getting 22149 Users.

These others did not run successfully ---- 

2) C:\GAMADV-XTD3>gam all users print forward enabledonly > ForwardedUsers.csv

Getting all Users in G Suite account (may take some time on a large account)...
Got 22149 Users...
done getting 22149 Users.

ERROR: enabledonly is not a valid argument for "gam <users> print forward"

3)  C:\GAMADV-XTD3>gam users print forwardingaddress enabledonly

ERROR: forwardingaddress is not a valid argument for "gam"



Ultimately, I would like the list of users with the forwarding enabled, then take a subset of those
users into another .csv.  I want to feed that csv BACK into the gam command to set forward
OFF for those users, and/or remove their forwardingaddress that I do not want them to use.  

Thanks for any help you can provide. 

=============================================
GAM VERSION INFO ---
C:\GAMADV-XTD3>gam version
GAM 5.11 - https://git.io/gam - pyinstaller
Python 3.8.3 64-bit final
google-api-python-client 1.9.3
Windows 10 10.0.17134  Multiprocessor Free AMD64
Path: C:\GAMADV-XTD3


Ross Scroggs

unread,
Jul 7, 2020, 5:18:08 PM7/7/20
to google-ap...@googlegroups.com
Susan,

You may be in the C:\GAMADV-XTD3> directory but you're running Basic GAM.
Open Control Panel/System/Advanced system settings/Environment Variables
In the bottom window System Variables, find Path and click Edit
Move C:\GAMADV-XTD3 ahead of G:\GAM
Click OK/OK/...

Restart Command Prompt/PowerShell 

gam redirect csv ForwardingUsers.csv all users print forward enabledonly
gam redirect csv ForwardingUsersForwardingAddresses.csv multiprocess csv ForwardingUsers.csv gam "~User" print forwardingaddresses

Ross

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/0141bd71-7824-4d85-9641-120c7576648do%40googlegroups.com.


--

Susan McClure

unread,
Jul 13, 2020, 5:14:54 PM7/13/20
to GAM for G Suite
Ross, 

Thanks for pointing that issue out.  I believe I fixed the environment settings, and restarted the Command Prompt.  I even rebooted and double checked the env. settings.
But, I must have something really messed up still because it is not working.  

C:\GAMADV-XTD3>gam version
GAM 5.11 - https://git.io/gam - pyinstaller
Jay Lee <jay...@gmail.com>
Python 3.8.3 64-bit final
google-api-python-client 1.9.3
Windows 10 10.0.17134  Multiprocessor Free AMD64
Path: C:\GAMADV-XTD3

C:\GAMADV-XTD3>gam redirect csv ForwardingUsers.csv all users print forward enabledonly

ERROR: redirect is not a valid argument for "gam"

C:\GAMADV-XTD3>gam all users print forward enabledonly > ./ForwardingUsers.csv
Getting all Users in G Suite account (may take some time on a large account)...
Got 22227 Users...
done getting 22227 Users.

ERROR: enabledonly is not a valid argument for "gam <users> print forward"
The last query created in this directory a "ForwardingUsers.csv" file of zero bytes.  

  
A "set" command on my command prompt shows me: 
 
........
 LOCALAPPDATA=C:\Users\smcclure\AppData\Local
LOGONSERVER=\\ADRICE-MUDDDC01
NSPR_NATIVE_THREADS_ONLY=1
NUMBER_OF_PROCESSORS=8
OneDrive=C:\Users\smcclure\OneDrive
OneDriveConsumer=C:\Users\smcclure\OneDrive
OS=Windows_NT
Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\GAMADV-XTD3;C:\Program Files (x86)\Vim\vim81;C:\Program Files\PuTTY\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\SafeNet\Authentication\SAC\x64;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Windows\CCM;C:\Program Files\SafeNet\Authentication\SAC\x32;C:\GAMADV-XTD3;C:\Program Files (x86)\Vim\vim81;C:\Users\smcclure\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\smcclure\AppData\Local\Programs\Python\Python37\;C:\Users\smcclure\AppData\Local\Microsoft\WindowsApps;C:\GAMADV-XTD;C:\Users\smcclure\AppData\Local\Box\Box Edit\;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC


Thanks for any insight you can provide. 

Susan

 


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


--
Ross Scroggs

Susan McClure

unread,
Jul 13, 2020, 5:15:41 PM7/13/20
to GAM for G Suite

Oleg Brendel

unread,
Jul 14, 2020, 10:40:36 AM7/14/20
to GAM for G Suite
Hi Ross,

I am trying the same. This is really useful.

Is there something special to take in consideration when running on MacOS?

doing
gam redirect csv ForwardingUsers.csv all users print forward enabledonly
then

gam redirect csv ForwardingUsersForwardingAddresses.csv multiprocess csv ForwardingUsers.csv gam "~User" print forwardingaddresses

just tells me obviously 
ERROR: File: ForwardingUsers.csv, [Errno 2] No such file or directory: 'ForwardingUsers.csv'

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


--
Ross Scroggs

Bradley Stinson

unread,
Jul 14, 2020, 10:58:13 AM7/14/20
to google-ap...@googlegroups.com
That error is saying it doesn't see the file you specified. You can drag and drop the file into the terminal window on mac and it will print the full path of the file. 



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


--
Ross Scroggs

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/532e5406-b930-4d69-9d5b-0928aa5d441bo%40googlegroups.com.

Oleg Brendel

unread,
Jul 14, 2020, 11:08:27 AM7/14/20
to google-ap...@googlegroups.com
Thanks

It puts the file in /Downloads 

lul

You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/TA9qa5P0Lbk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/CAC6ikXHK4zzUBRzSrs3JZM16LUPMgo3f8rxvdk2DJnHNyei_4w%40mail.gmail.com.


--

Oleg Brendel

LEAD OFFICE IT

oleg.b...@movinga.com

+4915904097704

www.movinga.de


This e-mail may contain confidential and/or privileged information. Any unauthorized copying, disclosure or distribution of the material in this e-mail is forbidden. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Thank you!

Movinga GmbH, Perleberger Straße 42, 10559 Berlin, Germany

HANDELSREGISTER: Amtsgericht Berlin (Charlottenburg), HRB 167739

GESCHÄFTSFÜHRUNG: Silvio Hinteregger, Tobias Hinteregger

Kim Nilsson

unread,
Jul 18, 2020, 1:51:57 PM7/18/20
to GAM for G Suite
Make sure you are in the directory with your files, then add a ./ in fornt of your filenames, so it knows to look and put them where you are.
Reply all
Reply to author
Forward
0 new messages